Skip to content

DOC Use DecisionBoundaryDisplay in SVM margin example - #34192

Merged
ArturoAmorQ merged 2 commits into
scikit-learn:mainfrom
EdenRochmanSharabi:doc/svm-margin-decision-boundary-display
Jun 5, 2026
Merged

ArturoAmorQ merged 2 commits into
scikit-learn:mainfrom
EdenRochmanSharabi:doc/svm-margin-decision-boundary-display

Conversation

@EdenRochmanSharabi

@EdenRochmanSharabi EdenRochmanSharabi commented Jun 3, 2026 •

Copy link
Copy Markdown
Contributor

Addresses #33980.

The plot_svm_margin example builds the decision boundary manually with
meshgrid, decision_function, and contourf. This replaces that block
with DecisionBoundaryDisplay.from_estimator, which is the recommended
API for plotting decision boundaries.

No change in visual output.

Replace manual meshgrid + decision_function + contourf with
DecisionBoundaryDisplay.from_estimator, which is the recommended
approach for plotting decision boundaries.
Comment thread examples/svm/plot_svm_margin.py Outdated
Comment on lines 74 to 75
y_min = -6
y_max = 6

@ArturoAmorQ ArturoAmorQ Jun 4, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
y_min = -6
y_max = 6
y_min = -5
y_max = 5

Comment thread examples/svm/plot_svm_margin.py Outdated
clf,
X,
ax=plt.gca(),
cmap=plt.get_cmap("RdBu"),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
cmap=plt.get_cmap("RdBu"),
cmap="RdBu",

Comment thread examples/svm/plot_svm_margin.py Outdated
cmap=plt.get_cmap("RdBu"),
alpha=0.5,
response_method="decision_function",
plot_method="contourf",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Already the default

Suggested change
plot_method="contourf",

Comment thread examples/svm/plot_svm_margin.py Outdated
@@ -73,12 +74,15 @@

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
x_max = 4.1

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This suggestion seems to bug on the github interface. Please check that x_max is not doubled in the blank line.

@AnneBeyer

Copy link
Copy Markdown
Member

Thank you for the PR, @EdenRochmanSharabi.

No change in visual output.

Please check the rendered docs. There are some additional spaces around the plots which should be fixed with @ArturoAmorQ's suggestions, but please double-check this after committing the changes.

Tighten axis limits, pass cmap as string, remove default plot_method.
@EdenRochmanSharabi

Copy link
Copy Markdown
Contributor Author

Applied all suggestions and checked the rendered docs, plots look good, no extra whitespace.

@ArturoAmorQ ArturoAmorQ left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @EdenRochmanSharabi. Merging!

@ArturoAmorQ
ArturoAmorQ merged commit d564524 into scikit-learn:main Jun 5, 2026
33 checks passed
prady0t pushed a commit to prady0t/scikit-learn that referenced this pull request Sep 2, 2026
@jeremiedbb jeremiedbb mentioned this pull request Sep 8, 2026
14 tasks done
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.

3 participants