在cross_val_predict里试了一下直接用random_state,结果报错
TypeError: cross_val_predict() got an unexpected keyword argument 'random_state'
1个回答
不能直接设定random_state,可以通过cv参数设定,cv设置成kfold,kfold中再设定random_state
from sklearn.model_selection import KFold, cross_val_predict
seed = 100
kfold = KFold(n_splits=4, random_state=seed)
cv_pred = cross_val_score(model, X, y, cv=kfold)
SofaSofa数据科学社区DS面试题库 DS面经
明白了,多谢!
-
猴老大
2019-11-16 15:41