7

Is

class sklearn.cross_validation.ShuffleSplit(
    n, 
    n_iterations=10, 
    test_fraction=0.10000000000000001, 
    indices=True, 
    random_state=None
)

the right way for 10*10fold CV in scikit-learn? (By changing the random_state to 10 different numbers)

Because I didn't find any random_state parameter in Stratified K-Fold or K-Fold and the separate from K-Fold are always identical for the same data.

If ShuffleSplit is the right, one concern is that it is mentioned

Note: contrary to other cross-validation strategies, random splits do not guarantee that all folds will be different, although this is still very likely for sizeable datasets

Is this always the case for 10*10 fold CV?

4

1 に答える 1

10

10*10 クロス検証の意味がわかりません。指定した ShuffleSplit 構成により、推定器の fit メソッドを 10 回呼び出すことになります。外側のループを明示的に使用してこれを 10 回呼び出す場合、または代わりに使用する場合は、1 つのループでテスト用に予約されたデータの 10% を使用して直接 100 回呼び出す場合:

>>> ss = ShuffleSplit(X.shape[0], n_iterations=100, test_fraction=0.1,
...     random_state=42)

k=10 で StratifiedKFold を 10 回実行する場合は、実行間でデータセットをシャッフルすることができます (これにより、fit メソッドが合計 100 回呼び出され、各呼び出しで 90% のトレーニングと 10% のテストが分割されます)。 :

>>> from sklearn.utils import shuffle
>>> from sklearn.cross_validation import StratifiedKFold, cross_val_score
>>> for i in range(10):
...    X, y = shuffle(X_orig, y_orig, random_state=i)
...    skf = StratifiedKFold(y, 10)
...    print cross_val_score(clf, X, y, cv=skf)
于 2011-11-26T20:05:39.993 に答える