Optional 'groups' parameter in GroupKFold().split()
See original GitHub issueIn the documentation of GroupKFold().split()
the parameter groups
is indicated as optional.
However, the following example fails with: The 'groups' parameter should not be None.
>>> import numpy as np
>>> from sklearn.model_selection import GroupKFold
>>> X = np.array([[1, 2], [3, 4], [5, 6], [7, 8]])
>>> y = np.array([1, 2, 3, 4])
>>> group_kfold = GroupKFold(n_splits=2)
>>> for train_index, test_index in group_kfold.split(X, y):
... print("TRAIN:", train_index, "TEST:", test_index)
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 331, in split
for train, test in super(_BaseKFold, self).split(X, y, groups):
File "/usr/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 100, in split
for test_index in self._iter_test_masks(X, y, groups):
File "/usr/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 112, in _iter_test_masks
for test_index in self._iter_test_indices(X, y, groups):
File "/usr/lib/python3.7/site-packages/sklearn/model_selection/_split.py", line 504, in _iter_test_indices
raise ValueError("The 'groups' parameter should not be None.")
ValueError: The 'groups' parameter should not be None.
Is this a documentation issue or a bug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
sklearn.model_selection.GroupKFold
K-fold iterator variant with non-overlapping groups. Each group will appear exactly once in the test set across all folds (the number of distinct...
Read more >Nested cross-validation with GroupKFold with sklearn
I mostly care about not mixing data from the same groups between train and test set. inner_cv = GroupKFold(n_splits=inner_fold) outer_cv = ...
Read more >model_selection.GroupKFold() - w10schools
Generate indices to split data into training and test set. Parameters: X : array-like, shape (n_samples, n_features). Training data, where ...
Read more >model_selection.GroupKFold() scikit-learn官方教程 _w3cschool
groups : array-like, with shape (n_samples,), optional. Group labels for the samples used while splitting the dataset into train/test set. Returns:.
Read more >machine learning - Time-series grouped cross-validation
kfold split 1 time series split 1 : train indices are [0, 1, 2, 3, ... df = generate_happy_case_dataframe() grouped_ts_validation_iterator ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can open a PR to do that.
So let’s override the docstring in the subclasses…?