Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a9ba660

Browse files
committed
ENH labels --> groups
1 parent 59bf211 commit a9ba660

6 files changed

Lines changed: 356 additions & 356 deletions

File tree

sklearn/model_selection/_search.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,15 +510,15 @@ def inverse_transform(self, Xt):
510510
"""
511511
return self.best_estimator_.transform(Xt)
512512

513-
def _fit(self, X, y, labels, parameter_iterable):
513+
def _fit(self, X, y, groups, parameter_iterable):
514514
"""Actual fitting, performing the search over parameters."""
515515

516516
estimator = self.estimator
517517
cv = check_cv(self.cv, y, classifier=is_classifier(estimator))
518518
self.scorer_ = check_scoring(self.estimator, scoring=self.scoring)
519519

520-
X, y, labels = indexable(X, y, labels)
521-
n_splits = cv.get_n_splits(X, y, labels)
520+
X, y, groups = indexable(X, y, groups)
521+
n_splits = cv.get_n_splits(X, y, groups)
522522
if self.verbose > 0 and isinstance(parameter_iterable, Sized):
523523
n_candidates = len(parameter_iterable)
524524
print("Fitting {0} folds for each of {1} candidates, totalling"
@@ -536,7 +536,7 @@ def _fit(self, X, y, labels, parameter_iterable):
536536
self.fit_params, return_parameters=True,
537537
error_score=self.error_score)
538538
for parameters in parameter_iterable
539-
for train, test in cv.split(X, y, labels))
539+
for train, test in cv.split(X, y, groups))
540540

541541
test_scores, test_sample_counts, _, parameters = zip(*out)
542542

@@ -856,7 +856,7 @@ def __init__(self, estimator, param_grid, scoring=None, fit_params=None,
856856
self.param_grid = param_grid
857857
_check_param_grid(param_grid)
858858

859-
def fit(self, X, y=None, labels=None):
859+
def fit(self, X, y=None, groups=None):
860860
"""Run fit with all sets of parameters.
861861
862862
Parameters
@@ -870,11 +870,11 @@ def fit(self, X, y=None, labels=None):
870870
Target relative to X for classification or regression;
871871
None for unsupervised learning.
872872
873-
labels : array-like, with shape (n_samples,), optional
873+
groups : array-like, with shape (n_samples,), optional
874874
Group labels for the samples used while splitting the dataset into
875875
train/test set.
876876
"""
877-
return self._fit(X, y, labels, ParameterGrid(self.param_grid))
877+
return self._fit(X, y, groups, ParameterGrid(self.param_grid))
878878

879879

880880
class RandomizedSearchCV(BaseSearchCV):
@@ -1084,7 +1084,7 @@ def __init__(self, estimator, param_distributions, n_iter=10, scoring=None,
10841084
n_jobs=n_jobs, iid=iid, refit=refit, cv=cv, verbose=verbose,
10851085
pre_dispatch=pre_dispatch, error_score=error_score)
10861086

1087-
def fit(self, X, y=None, labels=None):
1087+
def fit(self, X, y=None, groups=None):
10881088
"""Run fit on the estimator with randomly drawn parameters.
10891089
10901090
Parameters
@@ -1097,11 +1097,11 @@ def fit(self, X, y=None, labels=None):
10971097
Target relative to X for classification or regression;
10981098
None for unsupervised learning.
10991099
1100-
labels : array-like, with shape (n_samples,), optional
1100+
groups : array-like, with shape (n_samples,), optional
11011101
Group labels for the samples used while splitting the dataset into
11021102
train/test set.
11031103
"""
11041104
sampled_params = ParameterSampler(self.param_distributions,
11051105
self.n_iter,
11061106
random_state=self.random_state)
1107-
return self._fit(X, y, labels, sampled_params)
1107+
return self._fit(X, y, groups, sampled_params)

0 commit comments

Comments
 (0)