Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@thomasjpfan
Copy link
Member

@thomasjpfan thomasjpfan commented Jan 21, 2024

Reference Issues/PRs

Closes #22848

What does this implement/fix? Explain your changes.

This PR:

  • Adds private _UnsupportedGroupCVMixin mixin that updates the docstrings of CV splitters that do not support groups. It also includes a warning if groups are passed in.
  • For CV splitters, that define their own split method, this PR adds a warning there. For PredefinedSplitter and TimeSeriesSplitter, it raises a warning during split when the generator is created.

Any other comments?

Implementation wise, I moved ShuffleSplit._iter_indices to BaseShuffleSplit._iter_indicies, so that GroupShuffleSplit can directly inherit from BaseShuffleSplit. This way GroupShuffleSplit is not inheriting from a splitter that does not support groups.

@github-actions
Copy link

github-actions bot commented Jan 21, 2024

✔️ Linting Passed

All linting checks passed. Your pull request is in excellent shape! ☀️

Generated for commit: 5a364b2. Link to the linter CI: here

)
digits = load_digits()

pytestmark = pytest.mark.filterwarnings(
Copy link
Member

Choose a reason for hiding this comment

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

It is a bit weird for me to have this filter globally set for the file.

We should have our test catching the warning to make sure that we raise it when we expect or otherwise, we should raise an error.

Is there a particular reason to go fine grain here?

Copy link
Member Author

Choose a reason for hiding this comment

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

I converted this pytestmark to error instead and updated the tests.


class BaseShuffleSplit(_MetadataRequester, metaclass=ABCMeta):
"""Base class for ShuffleSplit and StratifiedShuffleSplit."""
"""Base class for ShuffleSplit and StratifiedShuffleSplit.
Copy link
Member

Choose a reason for hiding this comment

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

and the GroupShuffleSplit as well. Maybe "*ShuffleSplit is enough.

@glemaitre glemaitre self-requested a review January 22, 2024 11:10
Copy link
Member

@glemaitre glemaitre 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 it makes sense. I was actually not aware of the predefined splitter. I think that we don't document it in our API documentation.

I'll open a PR.

We do have it documented.

Copy link
Member

@adrinjalali adrinjalali left a comment

Choose a reason for hiding this comment

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

I have a secret plan to make all splitters support group and strata (#26821) to all splitters and to simply the interface a bit.

But in the meantime this is a nice fix.

Copy link
Member

@glemaitre glemaitre left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @thomasjpfan

@glemaitre glemaitre merged commit 1106c91 into scikit-learn:main Jan 26, 2024
glemaitre pushed a commit to glemaitre/scikit-learn that referenced this pull request Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KFold splitter falsely claims it supports groups

4 participants