Skip to content

[python-package] ignore scikit-learn 'check_sample_weight_equivalence' estimator check (fixes #6678) - #6679

Merged
StrikerRUS merged 2 commits into
masterfrom
more-scikit-learn
Oct 15, 2024
Merged

StrikerRUS merged 2 commits into
masterfrom
more-scikit-learn

Conversation

@jameslamb

@jameslamb jameslamb commented Oct 14, 2024 •

Copy link
Copy Markdown
Member

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:

https://github.com/microsoft/LightGBM/blob/bbeecc09af946c5ff9b84d1ada4749a9f26bca31/python-package/lightgbm/sklearn.py#L938-L947

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.

@jameslamb jameslamb added blocking CI will be unsuccessful until this is resolved. maintenance labels Oct 14, 2024
fsspec=2024.5.*
msgpack-python=1.0.*
pluggy=1.5.*
pyparsing=3.1.4

Copy link
Copy Markdown
Member 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

@borchero borchero left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@StrikerRUS StrikerRUS left a comment

Copy link
Copy Markdown
Collaborator

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!

@StrikerRUS StrikerRUS removed awaiting review blocking CI will be unsuccessful until this is resolved. labels Oct 15, 2024
@StrikerRUS
StrikerRUS merged commit 2b8a2bb into master Oct 15, 2024
@StrikerRUS
StrikerRUS deleted the more-scikit-learn branch October 15, 2024 11:17
@github-actions

Copy link
Copy Markdown
Contributor

This pull request has been automatically locked since there has not been any recent activity since it was closed.
To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

3 participants