神經網絡通常用於沒有使用CV的大型數據集 - 而且非常昂貴。在IRIS的情況下(每個物種50個樣本),您可能需要它.. 爲什麼不使用scikit-learn with different random seeds拆分培訓和測試?
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)
對於k在kfold:
- 分割數據不同地傳遞一個不同的值設定爲 「random_state」
- 使用_train使用_test
如果
試驗學會的淨你不喜歡隨機種子,並想要一個更有結構化的k倍分割,你可以使用這個採取的f rom here。 from sklearn.model_selection import KFold, cross_val_score
X = ["a", "a", "b", "c", "c", "c"]
k_fold = KFold(n_splits=3)
for train_indices, test_indices in k_fold.split(X):
print('Train: %s | test: %s' % (train_indices, test_indices))
Train: [2 3 4 5] | test: [0 1]
Train: [0 1 4 5] | test: [2 3]
Train: [0 1 2 3] | test: [4 5]