Skip to content

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

Closed

Description

@raghavrv

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

Activity

  1. added
    Easy
    on Oct 16, 2016
  2. added this to the 0.18.1 milestone on Oct 16, 2016
  3. polmauri commented on Oct 17, 2016

    @polmauri
    Contributor

    Can I give it a try?

  4. amueller commented on Oct 17, 2016

    @amueller
    Member

    @polmauri can you sent a PR please?

  5. raghavrv commented on Oct 17, 2016

    @raghavrv
    MemberAuthor

    PR @ #7683

  6. amueller commented on Oct 17, 2016

    @amueller
    Member

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

  7. amueller commented on Oct 25, 2016

    @amueller
    Member

    fixed in #7683

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Easy

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions