[MRG] Raise ValueError when trainset is empty in CVSplitters#12861
Merged
thomasjpfan merged 5 commits intoscikit-learn:masterfrom Mar 23, 2019
Merged
[MRG] Raise ValueError when trainset is empty in CVSplitters#12861thomasjpfan merged 5 commits intoscikit-learn:masterfrom
thomasjpfan merged 5 commits intoscikit-learn:masterfrom
Conversation
thomasjpfan
reviewed
Feb 13, 2019
| def test_shuffle_split_empty_trainset(CVSplitter): | ||
| cv = CVSplitter(test_size=.99) | ||
| X, y = [[1]], [0] # 1 sample | ||
| assert_raises_regexp( |
Member
There was a problem hiding this comment.
We seem to be moving to using pytest.raises for testing exceptions.
| 'samples={}'.format(self.p, n_samples) | ||
| ) | ||
| for combination in combinations(range(n_samples), self.p): | ||
| yield np.array(combination) |
Member
There was a problem hiding this comment.
Since we are python >= 3 now, maybe:
yield from map(np.array, combinations(range(n_samples), self.p))
Member
Author
There was a problem hiding this comment.
I'd rather not, since this is not related to the PR
jnothman
approved these changes
Feb 13, 2019
Member
Author
|
This is +2, @thomasjpfan can you merge this? |
thomasjpfan
reviewed
Mar 22, 2019
| ValueError, | ||
| match='With n_samples=1, test_size=0.99 and train_size=None, ' | ||
| 'the resulting train set will be empty'): | ||
| train_test_split(X, test_size=.99) |
Member
There was a problem hiding this comment.
Given that train_test_split is a commonly used function, a non-trival test such as X=[[1],[1],[1]] and test_size=0.67 would be useful.
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
…cikit-learn#12861)" This reverts commit 9314ff7.
xhluca
pushed a commit
to xhluca/scikit-learn
that referenced
this pull request
Apr 28, 2019
…cikit-learn#12861)" This reverts commit 9314ff7.
koenvandevelde
pushed a commit
to koenvandevelde/scikit-learn
that referenced
this pull request
Jul 12, 2019
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 #11028, following #11028 (comment)
What does this implement/fix? Explain your changes.
ValueError is raised in the CVSplitters if the resulting train set is empty. As far as I can tell, the test sets are never empty so no need to check.
No need to check either for the KFolds splitters or some
*Group*splitters, which have internal checks preventing the train set to be empty.Any other comments?