KFold(n_split, shuffle, random_state)
參數:n_splits:要划分的折數
shuffle: 每次都進行shuffle,測試集中折數的總和就是訓練集的個數
random_state:隨機狀態
from sklearn.model_selection import KFold kf = KFold(n_splits=3,random_state=1) for train, test in kf.split(titanic):
titanic為X,即要使用的數據集
