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

We should raise an error message when n_groups > actual number of groups #7681

Closed
raghavrv opened this issue Oct 16, 2016 · 5 comments
Closed
Labels
Easy Well-defined and straightforward way to resolve
Milestone

Comments

@raghavrv
Copy link
Member

raghavrv commented Oct 16, 2016

In LeaveOneGroupOut and LeavePGroupsOut, when the groups supplied at split time has fewer than or equal to n_groups, we should raise an error.

>>> import numpy as np
>>> from sklearn.model_selection import LeaveOneGroupOut, LeavePGroupsOut
>>> X = y = groups = np.ones(10)
>>> list(LeaveOneGroupOut.split(X, y, groups))
[(array([], dtype=int64), array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))]
>>> list(LeavePGroupsOut(n_groups=5).split(X, y, groups))
[]

This was like that before in the cross_validation module too. I think we should raise an appropriate error message in both cases (LeavePGroupsOut and LeaveOneGroupOut)?

@amueller @jnothman

@raghavrv raghavrv added Easy Well-defined and straightforward way to resolve Need Contributor labels Oct 16, 2016
@raghavrv raghavrv added this to the 0.18.1 milestone Oct 16, 2016
@polmauri
Copy link
Contributor

Can I give it a try?

polmauri added a commit to polmauri/scikit-learn that referenced this issue Oct 17, 2016
…cikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.
polmauri added a commit to polmauri/scikit-learn that referenced this issue Oct 17, 2016
…cikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.
@amueller
Copy link
Member

@polmauri can you sent a PR please?

@raghavrv
Copy link
Member Author

PR @ #7683

@amueller
Copy link
Member

damn I didn't see the link between the commits.

polmauri added a commit to polmauri/scikit-learn that referenced this issue Oct 18, 2016
…cikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.
polmauri added a commit to polmauri/scikit-learn that referenced this issue Oct 18, 2016
…cikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.
amueller pushed a commit that referenced this issue Oct 25, 2016
…#7681) (#7683)

* FIX raise an error message when n_groups > actual number of groups (#7681)

This change addresses issue #7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
@amueller
Copy link
Member

fixed in #7683

amueller pushed a commit to amueller/scikit-learn that referenced this issue Oct 25, 2016
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
amueller pushed a commit to amueller/scikit-learn that referenced this issue Oct 27, 2016
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
sergeyf pushed a commit to sergeyf/scikit-learn that referenced this issue Feb 28, 2017
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
Sundrique pushed a commit to Sundrique/scikit-learn that referenced this issue Jun 14, 2017
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
paulha pushed a commit to paulha/scikit-learn that referenced this issue Aug 19, 2017
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
maskani-moh pushed a commit to maskani-moh/scikit-learn that referenced this issue Nov 15, 2017
…scikit-learn#7681) (scikit-learn#7683)

* FIX raise an error message when n_groups > actual number of groups (scikit-learn#7681)

This change addresses issue scikit-learn#7681:
- Raise ValueError when n_groups > actual number of unique groups in LeaveOneGroupOut and LeavePGroupsOut.
- Add unit test.

* Make requested changes

- Check error message with `assert_raise_message`
- Pass parameters to `assert_raise_message` instead of defining functions

* Update condition and exception message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Well-defined and straightforward way to resolve
Projects
None yet
Development

No branches or pull requests

3 participants