ENH Adds warning & docs for splitters that do not support goups#28210
Merged
glemaitre merged 7 commits intoscikit-learn:mainfrom Jan 26, 2024
Merged
ENH Adds warning & docs for splitters that do not support goups#28210glemaitre merged 7 commits intoscikit-learn:mainfrom
glemaitre merged 7 commits intoscikit-learn:mainfrom
Conversation
glemaitre
reviewed
Jan 22, 2024
| ) | ||
| digits = load_digits() | ||
|
|
||
| pytestmark = pytest.mark.filterwarnings( |
Member
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
I converted this pytestmark to error instead and updated the tests.
glemaitre
reviewed
Jan 22, 2024
sklearn/model_selection/_split.py
Outdated
|
|
||
| class BaseShuffleSplit(_MetadataRequester, metaclass=ABCMeta): | ||
| """Base class for ShuffleSplit and StratifiedShuffleSplit.""" | ||
| """Base class for ShuffleSplit and StratifiedShuffleSplit. |
Member
There was a problem hiding this comment.
and the GroupShuffleSplit as well. Maybe "*ShuffleSplit is enough.
glemaitre
reviewed
Jan 22, 2024
adrinjalali
reviewed
Jan 22, 2024
Member
adrinjalali
left a comment
There was a problem hiding this comment.
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.
adrinjalali
approved these changes
Jan 26, 2024
glemaitre
pushed a commit
to glemaitre/scikit-learn
that referenced
this pull request
Feb 10, 2024
…it-learn#28210) Co-authored-by: Loïc Estève <loic.esteve@ymail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Reference Issues/PRs
Closes #22848
What does this implement/fix? Explain your changes.
This PR:
_UnsupportedGroupCVMixinmixin that updates the docstrings of CV splitters that do not support groups. It also includes a warning if groups are passed in.splitmethod, this PR adds a warning there. ForPredefinedSplitterandTimeSeriesSplitter, it raises a warning duringsplitwhen the generator is created.Any other comments?
Implementation wise, I moved
ShuffleSplit._iter_indicestoBaseShuffleSplit._iter_indicies, so thatGroupShuffleSplitcan directly inherit fromBaseShuffleSplit. This wayGroupShuffleSplitis not inheriting from a splitter that does not support groups.