700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > ML:模型训练/模型评估中常用的两种方法代码实现(留一法一次性切分训练和K折交叉验证

ML:模型训练/模型评估中常用的两种方法代码实现(留一法一次性切分训练和K折交叉验证

时间:2021-07-15 07:02:11

相关推荐

ML:模型训练/模型评估中常用的两种方法代码实现(留一法一次性切分训练和K折交叉验证

ML:模型训练/模型评估中常用的两种方法代码实现(留一法一次性切分训练和K折交叉验证训练)

目录

模型训练评估中常用的两种方法代码实现

T1、留一法一次性切分训练

T2、K折交叉验证训

模型训练评估中常用的两种方法代码实现

T1、留一法一次性切分训练

T2、K折交叉验证训

print("data split:")if kfold_flag: #T1、采用K折交叉验证训练kf = KFold(n_splits=2, shuffle=False) # K折交叉验证for train_index, test_index in kf.split(X_train):x_train_, y_train_ = X_train[train_index], y_train[train_index]x_test_, y_test_ = X_train[test_index], y_train[test_index]ModelC = ModelC_Train(XGBC_Best, x_train_,y_train_, x_test_,y_test_)else: #T2、采用K折交叉训练# train_test_splitx_train_, x_test_, y_train_, y_test_ = train_test_split(X_train, y_train, test_size=0.3, random_state=33)ModelC = ModelC_Train(XGBC_Best, x_train_, x_test_, y_train_, y_test_)

ML:模型训练/模型评估中常用的两种方法代码实现(留一法一次性切分训练和K折交叉验证训练)

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。