def objective(space):
estimator = XGBClassifier(
n_estimators=n_estimators,
max_depth=int(space['max_depth']),
min_child_weight=int(space['min_child_weight']),
gamma=space['gamma'],
subsample=space['subsample'],
colsample_bytree=space['colsample_bytree']
)
estimator.fit(
x_train,
y_train,
eval_set=[(x_train, y_train), (x_val, y_val)],
early_stopping_rounds=30,
verbose=False,
eval_metric='error'
)
score = accuracy_score(y_val, estimator.predict(x_val))
return {'loss': 1 - score, 'status': STATUS_OK}
model_tta_hyperopt.py 文件源码
python
阅读 19
收藏 0
点赞 0
评论 0
评论列表
文章目录