sklearn.base.clone() should not make deep copy of all parameters
See original GitHub issueduplicate #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 parameters
Describe 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 is None
, 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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (6 by maintainers)
I think what is more appropriate is to have a
deepcopy
parameter in clone to trigger or not copies of parameters.I think that we have an issue about this in the past: https://github.com/scikit-learn/scikit-learn/issues/5563. I started at some point a PR https://github.com/scikit-learn/scikit-learn/pull/9696 as well, which should be rebased and handle properly the cloning in the
GridSearchCV
.Then the assertion in
clone
will happen only when adeepcopy
is required.I reopen the issue and tag it as a duplicate.