[英]How to plot ROC_AUC curve for each folds in KFold Cross Validation using Keras Neural Network Classifier
[英]Kfold cross validation in sklearn gives different folds each time
我想在我的模型上实现KFold交叉验证。 由于我想与他人共享结果,因此我希望每次都有固定的结果。 我正在使用xgboost模型作为分类模型。 但是,每次我运行代码时,我的性能指标每次都会给出不同的结果,并且由于将shuffle
参数设置为False
而感到困惑。 另外,我不确定random_state
参数的作用(我阅读了文档),但是无论我尝试使用shuffle = False将其设置为固定数字,都无济于事。
kf = KFold(n_splits=5, shuffle = False)
for train_index, test_index in kf.split(X, y):
X_train, X_test = X.iloc[train_index], X.iloc[test_index]
y_train, y_test = y.iloc[train_index], y.iloc[test_index]
xgb = XGBClassifier(max_depth = 4)
...fit, predict, and compute performance metrics
在参数random_state
传递数字时,您正在修复内部随机数生成器的种子。 将来,如果再次将其设置为相同的数字,则生成的随机数序列将始终相同。 这样,您可以保证结果的可重复性,就像您想要的一样。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.