本文簡要介紹python語言中 sklearn.model_selection.RepeatedStratifiedKFold
的用法。
用法:
class sklearn.model_selection.RepeatedStratifiedKFold(*, n_splits=5, n_repeats=10, random_state=None)
重複分層K-Fold 交叉驗證器。
重複分層K-Fold n 次,每次重複使用不同的隨機化。
在用戶指南中閱讀更多信息。
- n_splits:整數,默認=5
折疊次數。必須至少為 2。
- n_repeats:整數,默認=10
cross-validator 需要重複的次數。
- random_state:int、RandomState 實例或無,默認=無
控製每次重複的隨機狀態的生成。傳遞 int 以在多個函數調用之間實現可重現的輸出。請參閱術語表。
參數:
注意:
隨機 CV 拆分器可能會為每個拆分調用返回不同的結果。您可以通過將
random_state
設置為整數來使結果相同。例子:
>>> import numpy as np >>> from sklearn.model_selection import RepeatedStratifiedKFold >>> X = np.array([[1, 2], [3, 4], [1, 2], [3, 4]]) >>> y = np.array([0, 0, 1, 1]) >>> rskf = RepeatedStratifiedKFold(n_splits=2, n_repeats=2, ... random_state=36851234) >>> for train_index, test_index in rskf.split(X, y): ... print("TRAIN:", train_index, "TEST:", test_index) ... X_train, X_test = X[train_index], X[test_index] ... y_train, y_test = y[train_index], y[test_index] ... TRAIN: [1 2] TEST: [0 3] TRAIN: [0 3] TEST: [1 2] TRAIN: [1 3] TEST: [0 2] TRAIN: [0 2] TEST: [1 3]
相關用法
- Python sklearn RepeatedKFold用法及代碼示例
- Python sklearn RegressorChain用法及代碼示例
- Python sklearn RandomTreesEmbedding用法及代碼示例
- Python sklearn RocCurveDisplay用法及代碼示例
- Python sklearn RadiusNeighborsTransformer用法及代碼示例
- Python sklearn RadiusNeighborsRegressor.radius_neighbors_graph用法及代碼示例
- Python sklearn RandomizedSearchCV用法及代碼示例
- Python sklearn RFE用法及代碼示例
- Python sklearn RadiusNeighborsClassifier用法及代碼示例
- Python sklearn RidgeCV用法及代碼示例
- Python sklearn RandomForestClassifier用法及代碼示例
- Python sklearn RadiusNeighborsTransformer.radius_neighbors_graph用法及代碼示例
- Python sklearn RANSACRegressor用法及代碼示例
- Python sklearn RobustScaler用法及代碼示例
- Python sklearn RandomForestRegressor用法及代碼示例
- Python sklearn RocCurveDisplay.from_estimator用法及代碼示例
- Python sklearn RadiusNeighborsRegressor用法及代碼示例
- Python sklearn RBF用法及代碼示例
- Python sklearn Ridge用法及代碼示例
- Python sklearn RadiusNeighborsTransformer.radius_neighbors用法及代碼示例
- Python sklearn RocCurveDisplay.from_predictions用法及代碼示例
- Python sklearn RidgeClassifierCV用法及代碼示例
- Python sklearn RadiusNeighborsRegressor.radius_neighbors用法及代碼示例
- Python sklearn RBFSampler用法及代碼示例
- Python sklearn RadiusNeighborsClassifier.radius_neighbors_graph用法及代碼示例
注:本文由純淨天空篩選整理自scikit-learn.org大神的英文原創作品 sklearn.model_selection.RepeatedStratifiedKFold。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。