def permutation_test_score(estimator, X, y, groups=None, cv=None, n_permutations=100, n_jobs=1, random_state=0, verbose=0, scoring=None):
 (X, y, groups) = indexable(X, y, groups)
 cv = check_cv(cv, y, classifier=is_classifier(estimator))
 scorer = check_scoring(estimator, scoring=scoring)
 random_state = check_random_state(random_state)
 score = _permutation_test_score(clone(estimator), X, y, groups, cv, scorer)
 permutation_scores = Parallel(n_jobs=n_jobs, verbose=verbose)((delayed(_permutation_test_score)(clone(estimator), X, _shuffle(y, groups, random_state), groups, cv, scorer) for _ in range(n_permutations)))
 permutation_scores = np.array(permutation_scores)
 pvalue = ((np.sum((permutation_scores >= score)) + 1.0) / (n_permutations + 1))
 return (score, permutation_scores, pvalue)

def permutation_test_score ( estimator , X , y , groups = None , cv = None , n_permutations = 100 , n_jobs = 1 , random_state = 0 , verbose = 0 , scoring = None ) : ( X , y , groups ) = indexable ( X , y , groups ) cv = check_cv ( cv , y , classifier = is_classifier ( estimator ) ) scorer = check_scoring ( estimator , scoring = scoring ) random_state = check_random_state ( random_state ) score = _permutation_test_score ( clone ( estimator ) , X , y , groups , cv , scorer ) permutation_scores = Parallel ( n_jobs = n_jobs , verbose = verbose ) ( ( delayed ( _permutation_test_score ) ( clone ( estimator ) , X , _shuffle ( y , groups , random_state ) , groups , cv , scorer ) for _ in range ( n_permutations ) ) ) permutation_scores = np . array ( permutation_scores ) pvalue = ( ( np . sum ( ( permutation_scores >= score ) ) + 1.0 ) / ( n_permutations + 1 ) ) return ( score , permutation_scores , pvalue )
evaluate the significance of a cross-validated score with permutations read more in the :ref:user guide <cross_validation> .