8000 Merge pull request #2299 from ogrisel/grid-scores · scikit-learn/scikit-learn@2df651b · GitHub
[go: up one dir, main page]

Skip to content

Commit 2df651b

Browse files
committed
Merge pull request #2299 from ogrisel/grid-scores
Rename cv_scores(_) back to grid_scores(_) to keep the name free
2 parents e0e900f + b0035bf commit 2df651b

File tree

12 files changed

+46
-52
lines changed

12 files changed

+46
-52
lines changed

doc/datasets/mldata_fixture.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ def setup_module():
4242

4343
def teardown_module():
4444
uninstall_mldata_mock()
45-
shutil.rmtree(custom_data_home)
45+
shutil.rmtree(custom_data_home)

examples/covariance/plot_sparse_cov.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
# plot the model selection metric
127127
pl.figure(figsize=(4, 3))
128128
pl.axes([.2, .15, .75, .7])
129-
pl.plot(model.cv_alphas_, np.mean(model.cv_scores, axis=1), 'o-')
129+
pl.plot(model.cv_alphas_, np.mean(model.grid_scores, axis=1), 'o-')
130130
pl.axvline(model.alpha_, color='.5')
131131
pl.title('Model selection')
132132
pl.ylabel('Cross-validation score')

examples/grid_search_digits.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
print()
6161
print("Grid scores on development set:")
6262
print()
63-
for params, mean_score, scores in clf.cv_scores_:
63+
for params, mean_score, scores in clf.grid_scores_:
6464
print("%0.3f (+/-%0.03f) for %r"
6565
% (mean_score, scores.std() / 2, params))
6666
print()

examples/plot_rfe_with_cross_validation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
pl.figure()
3333
pl.xlabel("Number of features selected")
3434
pl.ylabel("Cross validation score (nb of misclassifications)")
35-
pl.plot(range(1, len(rfecv.cv_scores_) + 1), rfecv.cv_scores_)
35+
pl.plot(range(1, len(rfecv.grid_scores_) + 1), rfecv.grid_scores_)
3636
pl.show()

examples/randomized_search.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939

4040

4141
# Utility function to report best scores
42-
def report(cv_scores, n_top=3):
43-
top_scores = sorted(cv_scores, key=itemgetter(1), reverse=True)[:n_top]
42+
def report(grid_scores, n_top=3):
43+
top_scores = sorted(grid_scores, key=itemgetter(1), reverse=True)[:n_top]
4444
for i, score in enumerate(top_scores):
4545
print("Model with rank: {0}".format(i + 1))
4646
print("Mean validation score: {0:.3f} (std: {1:.3f})".format(
@@ -67,7 +67,7 @@ def report(cv_scores, n_top=3):
6767
random_search.fit(X, y)
6868
print("RandomizedSearchCV took %.2f seconds for %d candidates"
6969
" parameter settings." % ((time() - start), n_iter_search))
70-
report(random_search.cv_scores_)
70+
report(random_search.grid_scores_)
7171

7272
# use a full grid over all parameters
7373
param_grid = {"max_depth": [3, None],
@@ -82,5 +82,5 @@ def report(cv_scores, n_top=3):
8282
grid_search.fit(X, y)
8383

8484
print("GridSearchCV took %.2f seconds for %d candidate parameter settings."
85-
% (time() - start, len(grid_search.cv_scores_)))
86-
report(grid_search.cv_scores_)
85+
% (time() - start, len(grid_search.grid_scores_)))
86+
report(grid_search.grid_scores_)

examples/svm/plot_rbf_parameters.py

-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@
105105
pl.axis('tight')
106106

107107
# plot the scores of the grid
108-
# cv_scores_ contains parameter settings and scores
109-
score_dict = grid.cv_scores_
108+
# grid_scores_ contains parameter settings and scores
109+
score_dict = grid.grid_scores_
110110

111111
# We extract just the scores
112112
scores = [x[1] for x in score_dict]

examples/svm/plot_svm_scale_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131
cv=ShuffleSplit(n=n_samples, train_size=train_size,
132132
n_iter=250, random_state=1))
133133
grid.fit(X, y)
134-
scores = [x[1] for x in grid.cv_scores_]
134+
scores = [x[1] for x in grid.grid_scores_]
135135

136136
scales = [(1, 'No scaling'),
137137
((n_samples * train_size), '1/n_samples'),

sklearn/covariance/graph_lasso_.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class GraphLassoCV(GraphLasso):
422422
`cv_alphas_`: list of float
423423
All penalization parameters explored.
424424
425-
`cv_scores`: 2D numpy.ndarray (n_alphas, n_folds)
425+
`grid_scores`: 2D numpy.ndarray (n_alphas, n_folds)
426426
Log-likelihood score on left-out data across folds.
427427
428428
See Also
@@ -551,14 +551,14 @@ def fit(self, X, y=None):
551551
% (i + 1, n_refinements, time.time() - t0))
552552

553553
path = list(zip(*path))
554-
cv_scores = list(path[1])
554+
grid_scores = list(path[1])
555555
alphas = list(path[0])
556556
# Finally, compute the score with alpha = 0
557557
alphas.append(0)
558-
cv_scores.append(cross_val_score(EmpiricalCovariance(), X,
558+
grid_scores.append(cross_val_score(EmpiricalCovariance(), X,
559559
cv=cv, n_jobs=self.n_jobs,
560560
verbose=inner_verbose))
561-
self.cv_scores = np.array(cv_scores)
561+
self.grid_scores = np.array(grid_scores)
562562
best_alpha = alphas[best_index]
563563
self.alpha_ = best_alpha
564564
self.cv_alphas_ = alphas

sklearn/feature_selection/rfe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ class RFECV(RFE, MetaEstimatorMixin):
261261
Selected (i.e., estimated best)
262262
features are assigned rank 1.
263263
264-
`cv_scores_` : array of shape [n_subsets_of_features]
264+
`grid_scores_` : array of shape [n_subsets_of_features]
265265
The cross-validation scores such that
266-
`cv_scores_[i]` corresponds to
266+
`grid_scores_[i]` corresponds to
267267
the CV score of the i-th subset of features.
268268
269269
`estimator_` : object
@@ -373,5 +373,5 @@ def fit(self, X, y):
373373
self.estimator_.set_params(**self.estimator_params)
374374
self.estimator_.fit(self.transform(X), y)
375375

376-
self.cv_scores_ = scores / n
376+
self.grid_scores_ = scores / n
377377
return self

sklearn/feature_selection/tests/test_rfe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def test_rfecv():
7272
rfecv = RFECV(estimator=SVC(kernel="linear"), step=1, cv=3)
7373
rfecv.fit(X, y)
7474
# non-regression test for missing worst feature:
75-
assert_equal(len(rfecv.cv_scores_), X.shape[1])
75+
assert_equal(len(rfecv.grid_scores_), X.shape[1])
7676
assert_equal(len(rfecv.ranking_), X.shape[1])
7777
X_r = rfecv.transform(X)
7878

0 commit comments

Comments
 (0)
0