Skip to content

ENH: Add xlim/ylim parameters to DecisionBoundaryDisplay.from_estimator #31693

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

ShauryaDusht
Copy link
Contributor

@ShauryaDusht ShauryaDusht commented Jul 2, 2025

Reference Issues/PRs

Towards #27462

What does this implement/fix? Explain your changes.

This PR adds xlim and ylim parameters to DecisionBoundaryDisplay.from_estimator() to allow users to override the automatic data-based plot limits.

  • Added xlim=None and ylim=None parameters to method signature
  • Added validation to ensure limits are tuples with min < max
  • Modified limit calculation to use custom limits when provided
  • Added documentation for both parameters
  • Maintains backward compatibility

Copy link

github-actions bot commented Jul 2, 2025

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 57dcb14. Link to the linter CI: here

Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

Could you please add some tests and a whats new entry: https://github.com/scikit-learn/scikit-learn/blob/main/doc/whats_new/upcoming_changes/README.md

Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also specify in the docstring that eps is ignored if both xlim and ylim given. Could we also move the the new kwargs to underneath eps?

@ShauryaDusht
Copy link
Contributor Author

Thanks for the swift review. I will add these changes soon.

@ShauryaDusht
Copy link
Contributor Author

Hi @lucyleeow
I've added the tests and the "whats new" entry.
Since DecisionBoundaryDisplay.from_estimator() depends on matplotlib (which took me a while to understand), I've marked it to be skipped in CI tests. However, when matplotlib is available, all tests pass (verified locally).

Copy link
Member

@lucyleeow lucyleeow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please place your tests in the existing decision boundary test: sklearn/inspection/_plot/tests/test_boundary_decision_display.py.
You will be able to use the test data and fixtures, so you don't have to repeat.

Your test cases are probably too long and more than what is actually needed. If you are using LLMs to help you with tests, please note that they tend to produce verbose code and careful oversight and review by yourself is probably best.

Note also that we don't use test classes. I am happy to take another look after you've carefully reviewed your tests. Thank you

@ShauryaDusht
Copy link
Contributor Author

ShauryaDusht commented Jul 7, 2025

I’ve moved the tests to sklearn/inspection/_plot/tests/test_boundary_decision_display.py as suggested.

Also removed test classes and refactored the cases to be more generalized

Thank you

@ShauryaDusht ShauryaDusht reopened this Jul 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants