permutation_test_score(estimator, X, y, groups=None, cv=None, n_permutations=100, n_jobs=None, random_state=0, verbose=0, scoring=None)¶
Evaluate the significance of a cross-validated score with permutations
Read more in the User Guide.
- estimatorestimator object implementing ‘fit’
The object to use to fit the data.
- Xarray-like of shape at least 2D
The data to fit.
The target variable to try to predict in the case of supervised learning.
- groupsarray-like, with shape (n_samples,), optional
Labels to constrain permutation within groups, i.e.
yvalues are permuted among samples with the same group identifier. When not specified,
yvalues are permuted among all samples.
When a grouped cross-validator is used, the group labels are also passed on to the
splitmethod of the cross-validator. The cross-validator uses them for grouping the samples while splitting the dataset into train/test set.
- scoringstring, callable or None, optional, default: None
A single string (see The scoring parameter: defining model evaluation rules) or a callable (see Defining your scoring strategy from metric functions) to evaluate the predictions on the test set.
If None the estimator’s score method is used.
- cvint, cross-validation generator or an iterable, optional
Determines the cross-validation splitting strategy. Possible inputs for cv are:
None, to use the default 5-fold cross validation,
integer, to specify the number of folds in a
An iterable yielding (train, test) splits as arrays of indices.
Refer User Guide for the various cross-validation strategies that can be used here.
Changed in version 0.22:
cvdefault value if None changed from 3-fold to 5-fold.
- n_permutationsinteger, optional
Number of times to permute
- n_jobsint or None, optional (default=None)
- random_stateint, RandomState instance or None, optional (default=0)
- verboseinteger, optional
The verbosity level.
The true score without permuting targets.
- permutation_scoresarray, shape (n_permutations,)
The scores obtained for each permutations.
The p-value, which approximates the probability that the score would be obtained by chance. This is calculated as:
(C + 1) / (n_permutations + 1)
Where C is the number of permutations whose score >= the true score.
The best possible p-value is 1/(n_permutations + 1), the worst is 1.0.
This function implements Test 1 in:
Ojala and Garriga. Permutation Tests for Studying Classifier Performance. The Journal of Machine Learning Research (2010) vol. 11