def GBM(self, argsDict):
max_depth = argsDict["max_depth"] + 10
subsample = argsDict["subsample"] * 0.1 + 0.5
#n_estimators = argsDict['n_estimators'] * 5 + 50
learning_rate = argsDict["learning_rate"] * 0.02 + 0.12
#gamma = argsDict["gamma"] * 0.1
#min_child_weight = argsDict["min_child_weight"] + 1
print("max_depth:" + str(max_depth), "learning_rate:" + str(learning_rate), "subsample:" + str(subsample))
params={
"max_depth":max_depth,
#"gamma":gamma,
'subsample' : subsample,
'learning_rate' : learning_rate,
#'subsample' : subsample,
#'min_child_weight': min_child_weight,
'objective': "multi:softmax",
'num_class': 7 ,
"eval_metric":'merror',
'silent':False,
# 'gpu_id':1,
# 'max_bin':16,
# 'tree_method': "gpu_exact",
# 'updater':'grow_gpu',
# 'n_gpus':-1,
# 'predictor' : "gpu_predictor",
}
num_round = 1
model=xgb.train(params,self.train, num_round, self.watchlist, feval=Xg_iter_precision)
cov_res=xgb.cv(params,self.train, num_round, nfold=5, feval=Xg_iter_precision)
#print(cov_res.head())
cov_rec=cov_res.tail(1)['test-precision_4_5_6-mean'].values
predicted=model.predict(self.test)
scoring=precision_score( self.test_y,predicted,average='micro',labels=[4,5,6])
print('precision is ',scoring)
print('cv_precision_4_5_6',cov_rec[0])
return -cov_rec[0]
Stock_Prediction_Model_XgBoost.py 文件源码
python
阅读 18
收藏 0
点赞 0
评论 0
评论列表
文章目录