Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We set
fitted_
attribute at the end of thefit()
methodLightGBM/python-package/lightgbm/sklearn.py
Line 770 in a77260f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed in the dmlc/xgboost#7230, they also replaced some other internal checks of estimator attributes with this method call.
I think that's a good idea, so only this method needs to know about the
fitted_
property. What do you think?That would mean changing the following to
if not self.__sklearn_is_fitted__()
:LightGBM/python-package/lightgbm/dask.py
Lines 1004 to 1005 in a77260f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree. I remember you were asking why do we use
if self._n_features is None
everywhere for checking that estimator is fitted when we haveself.fitted_
.LightGBM/python-package/lightgbm/sklearn.py
Line 857 in a77260f
#3883 (comment)
My answer was that it's because
self.fitted_
was introduced much later. Now we can replace everything withself.__sklearn_is_fitted__()
. And I think it will be clearer.But I'd prefer to do it in a follow-up PR, if you do not mind.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok yep, I'm fine with it being a followup