Permalink
Browse files

fix: permutation test score averages across folds

  • Loading branch information...
1 parent a509d4c commit 4eebf9bfb1b1a09746704c66bd065a7d86985a45 @satra satra committed Oct 21, 2011
Showing with 5 additions and 6 deletions.
  1. +5 −6 sklearn/cross_validation.py
@@ -805,13 +805,12 @@ def cross_val_score(estimator, X, y=None, score_func=None, cv=None, n_jobs=1,
def _permutation_test_score(estimator, X, y, cv, score_func):
"""Auxilary function for permutation_test_score"""
- y_test = list()
- y_pred = list()
+ avgscore = []
for train, test in cv:
- y_test.append(y[test])
- y_pred.append(estimator.fit(X[train], y[train]).predict(X[test]))
- return score_func(np.ravel(y_test), np.ravel(y_pred))
-
+ avgscore.append(score_func(y[test],
+ estimator.fit(X[train],
+ y[train]).predict(X[test])))
+ return np.mean(avgscore)
def _shuffle(y, labels, random_state):
"""Return a shuffled copy of y eventually shuffle among same labels."""

0 comments on commit 4eebf9b

Please sign in to comment.