DOC Use DecisionBoundaryDisplay in SVM margin example#34192
Conversation
Replace manual meshgrid + decision_function + contourf with DecisionBoundaryDisplay.from_estimator, which is the recommended approach for plotting decision boundaries.
| y_min = -6 | ||
| y_max = 6 |
There was a problem hiding this comment.
| y_min = -6 | |
| y_max = 6 | |
| y_min = -5 | |
| y_max = 5 |
| clf, | ||
| X, | ||
| ax=plt.gca(), | ||
| cmap=plt.get_cmap("RdBu"), |
There was a problem hiding this comment.
| cmap=plt.get_cmap("RdBu"), | |
| cmap="RdBu", |
| cmap=plt.get_cmap("RdBu"), | ||
| alpha=0.5, | ||
| response_method="decision_function", | ||
| plot_method="contourf", |
There was a problem hiding this comment.
Already the default
| plot_method="contourf", |
| @@ -73,12 +74,15 @@ | |||
There was a problem hiding this comment.
| x_max = 4.1 |
There was a problem hiding this comment.
This suggestion seems to bug on the github interface. Please check that x_max is not doubled in the blank line.
|
Thank you for the PR, @EdenRochmanSharabi.
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.
|
Applied all suggestions and checked the rendered docs, plots look good, no extra whitespace. |
ArturoAmorQ
left a comment
There was a problem hiding this comment.
Thanks @EdenRochmanSharabi. Merging!
Addresses #33980.
The
plot_svm_marginexample builds the decision boundary manually withmeshgrid,decision_function, andcontourf. This replaces that blockwith
DecisionBoundaryDisplay.from_estimator, which is the recommendedAPI for plotting decision boundaries.
No change in visual output.