Custom sklearn estimators implementing __sklearn_is_fitted__#1119
Custom sklearn estimators implementing __sklearn_is_fitted__#1119BenjaminBossan merged 6 commits intoskorch-dev:masterfrom
__sklearn_is_fitted__#1119Conversation
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for creating this PR so quickly. I think it's not quite correct yet, though, so please check my comment.
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for the update. Only a small comment, the rest looks good.
|
Hmm ~ not sure this test fail is related to the changes from this PR, is it? 🤔 (it's a flaky test) failed test |
It's a flaky test, I simply restarted the run. |
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for fixing the imports. I only now noticed an issue with the indentation, sorry for not noticing earlier. Please also add a brief entry to the CHANGES.md.
Two more in next commit Co-authored-by: Benjamin Bossan <BenjaminBossan@users.noreply.github.com>
BenjaminBossan
left a comment
There was a problem hiding this comment.
Thanks for implementing __sklearn_is_fitted__, the PR LGTM.
|
Thanks for the help 🙏 |
There were two issues in skorch with sklearn v1.8 that are now fixed: __sklearn_is_fitted__ should return a bool. Instead, we were just raising or returning None. Not sure if this was already wrong when added (#1119) or if the API changed later. Moreover, sklearn was now raising an error when using the SkorchDoctor class because of missing __sklearn_tags__. This class now inherits from BaseEstimator, resolving this issue. For good measure, I also tested locally with sklearn 1.7 to ensure that these changes are backwards compatible. Unrelated changes: Remove an unnecessary import and trailing whitespace. Added __sklearn_is_fitted__ to SkorchDoctor too.
There were two issues in skorch with sklearn v1.8 that are now fixed: __sklearn_is_fitted__ should return a bool. Instead, we were just raising or returning None. Not sure if this was already wrong when added (#1119) or if the API changed later. Moreover, sklearn was now raising an error when using the SkorchDoctor class because of missing __sklearn_tags__. This class now inherits from BaseEstimator, resolving this issue. For good measure, I also tested locally with sklearn 1.7 to ensure that these changes are backwards compatible. Unrelated changes: Remove an unnecessary import and trailing whitespace. Added __sklearn_is_fitted__ to SkorchDoctor too.
Closes #1118
Things to note:
__sklearn_is_fitted__docstring similartest_not_fitted_raisesintotest_not_init_raisesbut looking for advice on your preferences.test_not_fitted_raisestest is needed in all 3 oftests/test_net.py,tests/test_regressor.pyandtests/test_classifier.pyas the one intests/test_net.pycover it. Again, seeking maintainers' preferences here.cc @BenjaminBossan