输出结果
核心代码
num_round = 1000
n_estimators = cvresult.shape[0]
print ('running cross validation, with preprocessing function')
# do cross validation, for each fold
# the dtrain, dtest, param will be passed into fpreproc
# then the return value of fpreproc will be used to generate results of that fold
cvresult = xgb.cv(param, dtrain, num_round, nfold=5,
metrics={'ams@0.15', 'auc'},
early_stopping_rounds=10, seed = 0,
fpreproc = fpreproc)
print ('finish cross validation','\n',cvresult)
print ('train model using the best parameters by cv ... ')
bst = xgb.train( param, dtrain, n_estimators )
bst.save_model('data_input/xgboost/data_higgsboson/higgs_cv.model')