Generate indices to split data into training and test set. Parameters ---------- X : array-like of shape (n_samples, n_features) Training data, where `n_samples` is the number of samples and `n_features` is the number of features. y : array-l
(self, X, y=None, groups=None)
| 114 | __metadata_request__split = {"groups": metadata_routing.UNUSED} |
| 115 | |
| 116 | def split(self, X, y=None, groups=None): |
| 117 | """Generate indices to split data into training and test set. |
| 118 | |
| 119 | Parameters |
| 120 | ---------- |
| 121 | X : array-like of shape (n_samples, n_features) |
| 122 | Training data, where `n_samples` is the number of samples |
| 123 | and `n_features` is the number of features. |
| 124 | |
| 125 | y : array-like of shape (n_samples,) |
| 126 | The target variable for supervised learning problems. |
| 127 | |
| 128 | groups : array-like of shape (n_samples,), default=None |
| 129 | Group labels for the samples used while splitting the dataset into |
| 130 | train/test set. |
| 131 | |
| 132 | Yields |
| 133 | ------ |
| 134 | train : ndarray |
| 135 | The training set indices for that split. |
| 136 | |
| 137 | test : ndarray |
| 138 | The testing set indices for that split. |
| 139 | """ |
| 140 | X, y, groups = indexable(X, y, groups) |
| 141 | indices = np.arange(_num_samples(X)) |
| 142 | for test_index in self._iter_test_masks(X, y, groups): |
| 143 | train_index = indices[np.logical_not(test_index)] |
| 144 | test_index = indices[test_index] |
| 145 | yield train_index, test_index |
| 146 | |
| 147 | # Since subclasses must implement either _iter_test_masks or |
| 148 | # _iter_test_indices, neither can be abstract. |
nothing calls this directly
no test coverage detected