Repository navigation
Conversation
Member
|
The linked issue is not open for contribution, please read the full description #33980 (comment). In addition, please take a look at https://scikit-learn.org/stable/developers/contributing.html#automated-contributions-policy. With that in mind I'm closing this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Single-file edit to
examples/gaussian_process/plot_gpc_iris.py.Add
from sklearn.inspection import DecisionBoundaryDisplayto the imports.Drop the explicit
h,xx,yy, andnp.meshgridvariables.DecisionBoundaryDisplay.from_estimatorwill pick a sensible grid fromX.Replace the inner-loop body that calls
clf.predict_proba, reshapes to RGB, and callsplt.imshowwith:response_method="predict_proba"on a 3-class GPC returns a max-probability surface thatfrom_estimatorreduces to a single 2D response, drawn viacontourf. This is the same pattern DOC Use DecisionBoundaryDisplay in Plot RBF Parameters example #33952 used forplot_rbf_parameters.py.Keep the training-point scatter, axes limits, ticks, and title exactly as today (convert
plt.scatter/plt.xlim/plt.ylim/plt.xticks(())/plt.yticks(())/plt.title(...)toax.scatter/ax.set_xlimetc.). The training-point colors (np.array(["r","g","b"])[y]) and the LML title format string stay verbatim.Leave
plt.figure(figsize=(10, 5)),plt.tight_layout(), andplt.show()untouched.Update the example's module docstring to note that the colored region now visualizes the maximum class probability over the input plane (so the docstring stays accurate after the response_method change). One-sentence edit, no narrative restructuring.
PR title:
DOC Use DecisionBoundaryDisplay in plot_gpc_iris examplePR body (concise, factual):
Why this matters
Issue #33980 lists
examples/gaussian_process/plot_gpc_iris.pyas one of the four remaining examples that should be refactored to useDecisionBoundaryDisplay. The current implementation:h=0.02over the iris sepal-feature range,clf.predict_proba(np.c_[xx.ravel(), yy.ravel()])to get a(n_points, 3)probability array,(n_rows, n_cols, 3)and renders it as a direct RGB image viaplt.imshow(Z, extent=..., origin="lower"). Each pixel's color is the literal[p_0, p_1, p_2]posterior for that point.This RGB-probability rendering is unusual: most sklearn examples plot a single response (argmax label, or class-1 probability) via
contourf. The companion examples that #33980 wants to refactor (plot_svm_margin,plot_kmeans_digits,plot_forest_iris) all use the single-response style.This plan refactors
plot_gpc_iris.pyto the single-responseDecisionBoundaryDisplayform for consistency with the other examples in the gallery, and notes the trade-off in the PR body so reviewers can keep or revert.Testing
python examples/gaussian_process/plot_gpc_iris.pyruns to completion without exceptions and produces two subplots (Isotropic RBF, Anisotropic RBF) with the colored decision region behind the training points and the LML title preserved.mainvs the branch. The colored background style changes (RGB-imshow -> single-response contourf) - this is expected and called out in the PR body. The scatter points, titles, and overall layout must remain visually equivalent.sphinx-build doc -b html doc/_buildcompletes without new warnings for the gaussian_process gallery page.grep -n "predict_proba\|imshow" examples/gaussian_process/plot_gpc_iris.pyafter the edit returns no matches inside the loop body.grep -n "DecisionBoundaryDisplay" examples/gaussian_process/plot_gpc_iris.pyreturns one import match and one call-site match.ruff check examples/gaussian_process/plot_gpc_iris.pyreports no new findings.Fixes #33980
AI was used for assistance.