[dask] use more specific method names on _DaskLGBMModel #4004
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.
The Dask sklearn estimators in
lightgbm.dask
inherit from both theirlightgbm.sklearn
equivalent and a mixin called_DaskLGBMModel
.LightGBM/python-package/lightgbm/dask.py
Line 525 in 7880b79
Those equivalents from
lightgbm.sklearn
inherit from a mix of LightGBM internal classes and some mixins brought in fromsklearn
.Since
LGBMClassifier
is the first parent class in the method resolution order ("MRO") forDaskLGBMClassifier
, if it or any of the parent classes fromsklearn
introduce a method that conflicts with one of the method names in_DaskLGBMModel
, the_DaskLGBMModel
method won't be used, which could breakDaskLGBMClassifier
.To protect against this happening, this PR proposes changing the method names on
_DaskLGBMModel
to names that are less likely to conflict withsklearn
in the future. For example, it proposes changing_fit()
to_lgb_dask_fit()
, so that if ansklearn.base.BaseEstimator._fit()
is introduced in some future version ofsklearn
,DaskLGBMClassifier
will still use the correct method.All of the methods changed here are internal, so this should not have any user-facing impact.
Notes for reviewers
I also considered the pattern below for absolute certainty:
But I don't understand the full implications of doing that, so I decided against it.