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] ignore scikit-learn 'check_sample_weight_equivalence' estimator check (fixes #6678) #6679

Merged
merged 2 commits into from
Oct 15, 2024

Conversation

jameslamb
Copy link
Collaborator

@jameslamb jameslamb commented Oct 14, 2024

Fixes #6678

Fixes #6680

As of scikit-learn/scikit-learn#29818 (which will be in scikit-learn 1.6), scikit-learn contains an estimator check that enforces the following behavior:

check that setting sample_weight to zero / integer is equivalent to removing / repeating corresponding samples

This new check is breaking CI here... LightGBM does not work that way.

This PR proposes skipping that estimator check, just as scikit-learn is currently doing for HistGradientBoosting* estimators (code link).

Notes for Reviewers

We could modify LightGBM's scikit-learn estimators to match this expected behavior by excluding rows with weight=0 and creating copies of rows with int(weight)>=2 before passing it through to Dataset here:

train_set = Dataset(
data=_X,
label=_y,
weight=sample_weight,
group=group,
init_score=init_score,
categorical_feature=categorical_feature,
feature_name=feature_name,
params=params,
)

I don't support doing that... I think it'd add significant complexity (do count-based hyperparameters need to be modified? how does this affect Dask estimators?) for questionable benefit.

I think just skipping this compliance check is the right thing for lightgbm right now.

@@ -41,6 +41,7 @@ bokeh=3.1.*
fsspec=2024.5.*
msgpack-python=1.0.*
pluggy=1.5.*
pyparsing=3.1.4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While working on this, I discovered #6680.

Have reported that issue upstream: conda-forge/pyparsing-feedstock#48

For LightGBM's purposes, testing on an old version of Python, let's just pin it as we do other libraries in these environments.

@jameslamb jameslamb changed the title WIP: [python-package] ignore scikit-learn 'check_sample_weight_equivalence' estimator check (fixes #6678) [python-package] ignore scikit-learn 'check_sample_weight_equivalence' estimator check (fixes #6678) Oct 14, 2024
@jameslamb jameslamb marked this pull request as ready for review October 14, 2024 03:34
Copy link
Collaborator

@borchero borchero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think just skipping this compliance check is the right thing for lightgbm right now.

Agree with you!

Thanks for the fast fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants