KFold splitter falsely claims it supports groups

@thomasjpfan : (taken from https://github.com/scikit-learn/scikit-learn/pull/22765/files#r825487547)

> My mind is a little blown. So the current API for KFold.split has a groups parameter it never uses. Because of the inheritance structure, the [API docs for KFold.split](https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.KFold.html#sklearn.model_selection.KFold.split) says the group labels are used in KFold.
> 
> (This comment is not actionable)


I haven't looked at how to proceed here. It certainly shouldn't claim it supports `groups` in the docs, and we need to check how to fix the API if we can.

COMMENT:
I would be up for taking this issue if it is okay with you.

Just to be sure I understand this issue correctly: We want to overwrite the split method in the KFold cross-validator. The function signature should go from ```split(self, X, y=None, groups=None)``` to ```split(self, X, y=None)```.

Additionally, I have looked at the unit tests. It seems that some of the cross-validators are tested within the same test, where the ```groups``` argument is given to them all. What do you think is the best way of updating the tests. With if-statements? (see example below where I have added ```if isinstance(cv, KFold):``` multiple places)

```python
@ignore_warnings
def test_cross_validator_with_default_params():
    n_samples = 4
    n_unique_groups = 4
    n_splits = 2
    p = 2
    n_shuffle_splits = 10  # (the default value)

    X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
    X_1d = np.array([1, 2, 3, 4])
    y = np.array([1, 1, 2, 2])
    groups = np.array([1, 2, 3, 4])
    loo = LeaveOneOut()
    lpo = LeavePOut(p)
    kf = KFold(n_splits)
    skf = StratifiedKFold(n_splits)
    lolo = LeaveOneGroupOut()
    lopo = LeavePGroupsOut(p)
    ss = ShuffleSplit(random_state=0)
    ps = PredefinedSplit([1, 1, 2, 2])  # n_splits = np of unique folds = 2
    sgkf = StratifiedGroupKFold(n_splits)

    loo_repr = "LeaveOneOut()"
    lpo_repr = "LeavePOut(p=2)"
    kf_repr = "KFold(n_splits=2, random_state=None, shuffle=False)"
    skf_repr = "StratifiedKFold(n_splits=2, random_state=None, shuffle=False)"
    lolo_repr = "LeaveOneGroupOut()"
    lopo_repr = "LeavePGroupsOut(n_groups=2)"
    ss_repr = (
        "ShuffleSplit(n_splits=10, random_state=0, test_size=None, train_size=None)"
    )
    ps_repr = "PredefinedSplit(test_fold=array([1, 1, 2, 2]))"
    sgkf_repr = "StratifiedGroupKFold(n_splits=2, random_state=None, shuffle=False)"

    n_splits_expected = [
        n_samples,
        comb(n_samples, p),
        n_splits,
        n_splits,
        n_unique_groups,
        comb(n_unique_groups, p),
        n_shuffle_splits,
        2,
        n_splits,
    ]

    for i, (cv, cv_repr) in enumerate(
        zip(
            [loo, lpo, kf, skf, lolo, lopo, ss, ps, sgkf],
            [
                loo_repr,
                lpo_repr,
                kf_repr,
                skf_repr,
                lolo_repr,
                lopo_repr,
                ss_repr,
                ps_repr,
                sgkf_repr,
            ],
        )
    ):
        # Test if get_n_splits works correctly
        if isinstance(cv, KFold):
            assert n_splits_expected[i] == cv.get_n_splits(X, y)
        else:
            assert n_splits_expected[i] == cv.get_n_splits(X, y, groups)

        # Test if the cross-validator works as expected even if
        # the data is 1d
        if isinstance(cv, KFold):
            np.testing.assert_equal(
                list(cv.split(X, y)), list(cv.split(X_1d, y))
            )
        else:
            np.testing.assert_equal(
                list(cv.split(X, y, groups)), list(cv.split(X_1d, y, groups))
            )
        # Test that train, test indices returned are integers
        if isinstance(cv, KFold):
            for train, test in cv.split(X, y):
                assert np.asarray(train).dtype.kind == "i"
                assert np.asarray(test).dtype.kind == "i"
        else:
            for train, test in cv.split(X, y, groups):
                assert np.asarray(train).dtype.kind == "i"
                assert np.asarray(test).dtype.kind == "i"

        # Test if the repr works without any errors
        assert cv_repr == repr(cv)

    # ValueError for get_n_splits methods
    msg = "The 'X' parameter should not be None."
    with pytest.raises(ValueError, match=msg):
        loo.get_n_splits(None, y, groups)
    with pytest.raises(ValueError, match=msg):
        lpo.get_n_splits(None, y, groups)
```

Labels: Documentation, Moderate, module:model_selection