Skip to content

MAINT Use class_of_interest in DecisionBoundaryDisplay #772

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

Merged

Conversation

ArturoAmorQ
Copy link
Collaborator

Since scikit-learn v1.4 DecisionBoundaryDisplay accepts class_of_interest for multiclass visualization. This feature is promised in the current version of the MOOC.

Notice that, as it requires updating the minimal version, it may change the experience of current enrolled participants.

@glemaitre glemaitre self-requested a review April 26, 2024 13:18
@glemaitre
Copy link
Collaborator

I see an occurrence where we could reuse the axis from the first display, it seems more natural.

import matplotlib.pyplot as plt
import matplotlib as mpl
import seaborn as sns

from sklearn.inspection import DecisionBoundaryDisplay

tab10_norm = mpl.colors.Normalize(vmin=-0.5, vmax=8.5)

palette = ["tab:blue", "tab:green", "tab:orange"]
disp = DecisionBoundaryDisplay.from_estimator(
    tree,
    data_train,
    response_method="predict",
    cmap="tab10",
    norm=tab10_norm,
    alpha=0.5,
)
sns.scatterplot(
    data=penguins,
    x=culmen_columns[0],
    y=culmen_columns[1],
    hue=target_column,
    palette=palette,
    ax=disp.ax_,
)
disp.ax_.legend(bbox_to_anchor=(1.05, 1), loc="upper left")
_ = disp.ax_.set_title("Decision boundary using a decision tree")

@glemaitre glemaitre changed the base branch from main to update-to-scikit-learn-1.6 April 2, 2025 09:27
Copy link
Collaborator

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM otherwise.

@ogrisel
Copy link
Collaborator

ogrisel commented Apr 2, 2025

If this is already there in 1.4, we can directly target main, no?

@ArturoAmorQ
Copy link
Collaborator Author

If this is already there in 1.4, we can directly target main, no?

According to #789, we are currently running on v1.3. I confirmed this by running sklearn.__version__ on the mooc.

Copy link
Collaborator

@ogrisel ogrisel left a comment

Choose a reason for hiding this comment

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

I did another pass of rephrasing.

+1 for merging to update-to-scikit-learn-1.6 and pushing a resync of the notebooks / exercises in that branch to check the CI.

@ogrisel ogrisel merged commit f01f612 into INRIA:update-to-scikit-learn-1.6 Apr 3, 2025
1 check passed
@ArturoAmorQ ArturoAmorQ deleted the class_of_interest branch April 3, 2025 12:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants