Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[python-package] require scikit-learn>=0.24.2, make scikit-learn estimators compatible with scikit-learn>=1.6.0dev #6651

Open
wants to merge 38 commits into
base: master
Choose a base branch
from
Open
Changes from 9 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
1adb77b
__sklearn_tags__ replacing sklearn's BaseEstimator._more_tags_
vnherdeiro Sep 11, 2024
8ed87d2
fixing tags dict -> dataclass
vnherdeiro Sep 11, 2024
32ec431
fixing wrong import
vnherdeiro Sep 11, 2024
ade9798
remove type hint
vnherdeiro Sep 11, 2024
2085a12
remove type hint
vnherdeiro Sep 11, 2024
a9ec348
fix linting
vnherdeiro Sep 11, 2024
fcc4e12
triggering new CI (scikit-learn dev has changed)
vnherdeiro Sep 14, 2024
3b15646
bringing back _more_tags, adding convertsion from more_tags to sklear…
vnherdeiro Sep 15, 2024
34d9eb4
lint fix
vnherdeiro Sep 15, 2024
6d20ef8
Update python-package/lightgbm/sklearn.py
vnherdeiro Sep 16, 2024
d715311
adressing PR comments
vnherdeiro Sep 16, 2024
c4ec9a4
move comment
jameslamb Sep 16, 2024
b0a4703
updates
jameslamb Sep 21, 2024
7eb861a
remove uses of super()
jameslamb Sep 24, 2024
b137ba2
fix version constraint in lint job, add one more comment
jameslamb Sep 24, 2024
d1915c0
Update python-package/lightgbm/sklearn.py
jameslamb Sep 24, 2024
6cf2158
Merge branch 'master' into fix_sklearn_more_tags_deprecation
jameslamb Sep 26, 2024
b5663aa
Merge branch 'fix_sklearn_more_tags_deprecation' of github.com:vnherd…
jameslamb Sep 26, 2024
118efd9
use scikit-learn 1.6 nightlies again, move some code to compat.py, re…
jameslamb Oct 2, 2024
4fb82f3
optionally use validate_data(), starting in scikit-learn 1.6
jameslamb Oct 3, 2024
c42c53d
fix validate_data() for older versions, update tests
jameslamb Oct 4, 2024
58d77e7
Merge branch 'master' of github.com:microsoft/LightGBM into fix_sklea…
jameslamb Oct 4, 2024
33fb5b6
more changes
jameslamb Oct 4, 2024
6689faa
fix n_features_in setting
jameslamb Oct 5, 2024
9a05670
fix return type
jameslamb Oct 5, 2024
815433f
remove now-unnecessary _LGBMCheckXY()
jameslamb Oct 5, 2024
ffebe41
correct comment
jameslamb Oct 5, 2024
722474d
Merge branch 'master' of github.com:microsoft/LightGBM into fix_sklea…
jameslamb Oct 6, 2024
f2cb2fe
Apply suggestions from code review
jameslamb Oct 6, 2024
86b5ab3
move __version__ import to compat.py, test with all ML tasks
jameslamb Oct 6, 2024
125f4ea
just set the setters and deleters
jameslamb Oct 6, 2024
4233d70
set floor of scikit-learn>=0.24.2, fix ordering of n_features_in_ set…
jameslamb Oct 6, 2024
330df3f
fix conflicts
jameslamb Oct 6, 2024
e8e4cdb
Update python-package/lightgbm/sklearn.py
jameslamb Oct 6, 2024
0b0ea24
Merge branch 'master' into fix_sklearn_more_tags_deprecation
jameslamb Oct 6, 2024
f22e494
forgot to commit ... fix comment
jameslamb Oct 7, 2024
b124797
Merge branch 'master' of github.com:microsoft/LightGBM into fix_sklea…
jameslamb Oct 7, 2024
beab71c
Merge branch 'fix_sklearn_more_tags_deprecation' of github.com:vnherd…
jameslamb Oct 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python-package/lightgbm/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,18 @@ def _more_tags(self) -> Dict[str, Any]:
},
}

def __sklearn_tags__(self):
tags = super().__sklearn_tags__()
vnherdeiro marked this conversation as resolved.
Show resolved Hide resolved
more_tags = self._more_tags()
tags.input_tags.allow_nan = more_tags.pop("allow_nan", False)
tagged_input_types = more_tags.pop("X_types", [])
tags.input_tags.sparse = "sparse" in tagged_input_types
tags.target_tags.one_d_labels = "1dlabels" in tagged_input_types
tags._xfail_checks = more_tags.pop("_xfail_checks", {})
vnherdeiro marked this conversation as resolved.
Show resolved Hide resolved
if more_tags or set(tagged_input_types).difference({"2darray", "sparse", "1dlabels"}):
_log_warning(f"Some tags sklearn tag values are missing from __sklearn_tags__: `{more_tags}`")
vnherdeiro marked this conversation as resolved.
Show resolved Hide resolved
return tags

def __sklearn_is_fitted__(self) -> bool:
return getattr(self, "fitted_", False)

Expand Down
Loading