Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH HTML repr show best estimator in *SearchCV when refit=True #28722

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
merged 8 commits into from
Apr 11, 2024

Conversation

Charlie-XIAO
Copy link
Contributor

@Charlie-XIAO Charlie-XIAO commented Mar 28, 2024

Closes #21058 (supersedes).
Closes #20971.

This PR shows the best estimator in *SearchCV HTML repr whenever possible with a clear label saying it is best_estimator_.

Setup code:

from sklearn import set_config
from sklearn.datasets import make_classification
from sklearn.dummy import DummyClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import GridSearchCV
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler

set_config(display="diagram")

X, y = make_classification(random_state=42)

pipeline = Pipeline([("scale", StandardScaler()), ("clf", DummyClassifier())])
param_grid = {"clf": [DummyClassifier(), LogisticRegression()]}

Then try running:

GridSearchCV(pipeline, param_grid) GridSearchCV(pipeline, param_grid, refit=False).fit(X, y) GridSearchCV(pipeline, param_grid).fit(X, y)
main image image image
PR image image image

Copy link

github-actions bot commented Mar 28, 2024

✔️ Linting Passed

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

Generated for commit: c1904c5. Link to the linter CI: here

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

Copy link
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM

@thomasjpfan thomasjpfan enabled auto-merge (squash) April 11, 2024 19:19
@thomasjpfan thomasjpfan merged commit bf61674 into scikit-learn:main Apr 11, 2024
28 checks passed
@Charlie-XIAO Charlie-XIAO deleted the search-cv-html branch April 11, 2024 23:48
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.

incompatible HTML representation for RandomizedSearchCV
3 participants