sklearn.model_selection.permutation_test_score?
sklearn.model_selection.permutation_test_score(estimator, X, y, *, groups=None, cv=None, n_permutations=100, n_jobs=None, random_state=0, verbose=0, scoring=None)
[源碼]
通過排列評估交叉驗證準確率的重要性
在用戶指南中閱讀更多內容。
參數 | 說明 |
---|---|
estimator | estimator object implementing ‘fit’ 用于擬合數據的對象。 |
X | array-like of shape at least 2D 用于擬合的數據。 |
y | array-like of shape (n_samples,) or (n_samples, n_outputs) or None 在監督學習的情況下要嘗試預測的目標變量。 |
groups | array-like of shape (n_samples,), default=None 標簽用于限制組內的排列,即,在具有相同組標識的樣本之間排列 y 值。如果未指定,則在所有樣本中排列y 值。使用分組的交叉驗證器時,組標簽也將傳遞給它交叉驗證器的 split 方法。交叉驗證器使用它們對樣本進行分組,同時將數據集切分為訓練集或測試集。 |
scoring | str or callable, default=None 單個str(請參閱評分參數:定義模型評估規則)或可調用項(請參閱從度量函數定義評分策略)以評估測試集上的預測。 |
cv | int, cross-validation generator or an iterable, default=None 確定交叉驗證切分策略。cv值可以輸入: - None,默認使用5折交叉驗證 - int,用于指定 (Stratified)KFold 的折數- CV splitter, - 可迭代輸出訓練集和測試集的切分作為索引數組 對于int或 None輸入,如果估計器是分類器,并且 y 是二分類或多分類,則使用StratifiedKFold 。在所有其他情況下,均使用KFold 。有關可在此處使用的各種交叉驗證策略,請參閱用戶指南。 在版本0.22中:如果 cv 為None,默認值從3折更改為5折。 |
n_permutations | int, default=100 排列的次數 y 。 |
n_jobs | int, default=None 用于進行計算的CPU數量。 None 除非在joblib.parallel_backend 環境中,否則表示1 。 -1 表示使用所有處理器。有關更多詳細信息,請參見詞匯表。 |
random_state | int, RandomState instance or None, default=0 傳遞一個整數以獲得可重復的輸出,以在樣本之間對 y 值進行排列 。請參閱詞匯表。 |
verbose | int, default=0 詳細程度。 |
返回值 | 說明 |
---|---|
score | float 沒有排列目標的真實準確率。 |
permutation_scores | array of shape (n_permutations,) 每個排列獲得的準確率。 |
pvalue | float p值,近似于隨機獲得準確率的概率。計算公式為: (C + 1) / (n_permutations + 1) 其中C是準確率大于等于真實準確率的排列數量。 最好的p值是1 /(n_permutations +1),最差的是1.0。 |
注
此功能在以下位置實現測試1:
Ojala and Garriga. Permutation Tests for Studying Classifier Performance. The Journal of Machine Learning Research (2010) vol. 11 [pdf].