Python:十折交叉驗證sklearn KFold 的使用

from sklearn.model_selection import KFold
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
import numpy as np
X,y = load_iris(return_X_y=True)
KF = KFold(n_splits=10,shuffle=False,random_state=100)
model = RandomForestClassifier()
for train_index,test_index in KF.split(X):
    print("train_index:{},test_index:{}".format(train_index,test_index))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章