-
-
Notifications
You must be signed in to change notification settings - Fork 25.8k
sklearn.base.clone() should not make deep copy of all parameters #16137
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
Comments
It needs to work with set_params too, which would entail you validate in
multiple places (or make heavy use of property setters)
|
Basically, this is an API choice and we have a lot of code that relies on the current API. Rephrasing @jnothman comment, making such changes will alter the way So basically, your estimator should not pass the In the short-term, I don't think that we can change anything about it. In the long-term, one could write a SLEP finding an alternative pattern that provides a much better design without degrading the performance. |
This comment has been minimized.
This comment has been minimized.
@glemaitre I don't see how this would alter any current functionality, since the esimators in the sklearn library already adhere to the desired API. Note that I am not suggesting that code be inserted into, say, |
This comment has been minimized.
This comment has been minimized.
If change |
To be clear, I often have to implement
8000
models in the following way, specifically so that they will function correctly with
This usually happens when I have some very resource-heavy item that |
@glemaitre perhaps a warning would be more appropriate? |
I think what is more appropriate is to have a I think that we have an issue about this in the past: #5563. I started at some point a PR #9696 as well, which should be rebased and handle properly the cloning in the Then the assertion in |
I reopen the issue and tag it as a duplicate. |
closing for the same reason as #5563 (comment) |
duplicate #5563
related to #9696
Describe the workflow you want to enable
sklearn.base.clone
does not raise a RunTimeError when the constructor alters the model parametersDescribe your proposed solution
Delete lines 75-82 in sklearn/base.py
Describe alternatives you've considered, if relevant
I currently alter parameters in other methods, and there is no complaint. Since lines 75-82 don't prevent me from altering the parameters, and they force me to hide that functionality in other methods, they are counterproductive.
It is a normal python practice to set defaults by accepting
None
as a parameter, and then if the value isNone
, to set the parameter to be some other thing. It is not clear what is gained by preventing this behavior. Specifically, sklearn exposes interfaces that are very helpful when building pipelines with my own custom models. This particular behavior makes building my custom modules hard.The text was updated successfully, but these errors were encountered: