如何使用Python在H2o库中的GBM中重用cross_validation_fold_assignment() [英] How to reuse cross_validation_fold_assignment() with GBM in H2o library with Python
本文介绍了如何使用Python在H2o库中的GBM中重用cross_validation_fold_assignment()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用H2o库运行模型.我进行了5折交叉验证.
I run my model with H2o library. I run with 5 folds cross-validation.
model = H2OGradientBoostingEstimator(
balance_classes=True,
nfolds=5,
keep_cross_validation_fold_assignment=True,
seed=1234)
model.train(x=predictors,y=response,training_frame=data)
print('rmse: ',model.rmse(xval=True))
print('R2: ',model.r2(xval=True))
data_nfolds = model.cross_validation_fold_assignment()
我得到了交叉验证折页作业.我尝试将其重用于具有其他参数(例如ntrees或Stopping_rounds)的新模型,但是我没有在文档中找到它.
I got the cross-validation fold assignment. I try to reuse it for a new model with other parameters such as ntrees or stopping_rounds, but I did not find it in the documents.
推荐答案
我找到了答案.
nfolds_index = h2o.import_file('myfile_index.csv')
nfolds_index.set_names(["fold_numbers"])
data = data.cbind(nfolds_index)
model2 = H2OGradientBoostingEstimator( seed=1234)
model2.train(x=predictors,y=response,training_frame=data, fold_column="fold_numbers")
print('rmse: ',model2.rmse(xval=True))
print('R2: ',model2.r2(xval=True))
这篇关于如何使用Python在H2o库中的GBM中重用cross_validation_fold_assignment()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文