Python scikit-learn: cannot clone an object ... since the constructor does not seem to set a parameter

I changed the sklearn.base.clone class because visible_config not being copied correctly. I do not know how to fix this. The documentation states that sklearn.base.clone uses deepcopy() , so you should not copy visible_config as well? Can someone explain what I can try here? Thanks!

+7
python numpy scikit-learn copy
source share
1 answer

Without seeing your code, it's hard to say exactly what went wrong, but you are violating the scikit-learn API convention. The constructor in the evaluation should set attributes only for values ​​that the user passes as arguments. All calculations must be performed in fit , and if fit must save the result of the calculation, it must do so in the attribute with a trailing underscore ( _ ). This convention means that clone and meta-evaluations such as GridSearchCV work.

(*) If you have ever seen an estimate in the main code base that violates this rule: this will be an error, and patches are welcome.

+4
source share

All Articles