8000 FIX clone to handle dict and GridSearchCV changing original params by adrinjalali · Pull Request #26786 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@adrinjalali
Copy link
Member

Fixes #26737

It seems GridSearchCV actually changes the original given parameter if the parameter is an estimator.

This PR adds handling dict to clone, and fixes the issue in GridSearchCV.

@github-actions
Copy link
github-actions bot commented Jul 6, 2023

✔️ Linting Passed

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

Generated for commit: 01809d6. Link to the linter CI: here

@betatim
Copy link
Member
betatim commented Jul 12, 2023

Test failure is because pipe.named_steps["clf"] is None. I'm a bit puzzled why :-/

@betatim
Copy link
Member
betatim commented Jul 12, 2023

Test failure is because pipe.named_steps["clf"] is None. I'm a bit puzzled why :-/

Confusion solved. The SearchCV clones the estimator (in this case a pipeline). This means that, of course, the original pipe is not modified. Instead we should look at the best_estimator_ attribute of the SearchCV instance to access the refitted estimator. Which in this case is the pipeline we are looking for.

Copy link
Member
@betatim betatim left a comment

Choose a reason for hiding this comment

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

LGTM

@betatim betatim added the Waiting for Second Reviewer First reviewer is done, need a second one! label Jul 13, 2023
@adrinjalali
Copy link
Member Author

@ogrisel this changes clone, wanna have a look?

8000
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.

I think this change makes sense and is much better than the double clone from before. LGTM

@thomasjpfan thomasjpfan merged commit ba6896e into scikit-learn:main Jul 13, 2023
@adrinjalali adrinjalali deleted the gs/clone branch July 14, 2023 09:44
punndcoder28 pushed a commit to punndcoder28/scikit-learn that referenced this pull request Jul 29, 2023
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Sep 18, 2023
jeremiedbb pushed a commit that referenced this pull request Sep 20, 2023
…26786)

Co-authored-by: Thomas J. Fan <thomasjpfan@gmail.com>
REDVM pushed a commit to REDVM/scikit-learn that referenced this pull request Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

module:model_selection Waiting for Second Reviewer First reviewer is done, need a second one!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

0