我hyperopt
用来寻找catboost
回归量的最佳超参数。我正在遵循本指南。相关部分是:
ctb_reg_params = {
'learning_rate': hp.choice('learning_rate', np.arange(0.05, 0.31, 0.05)),
}
ctb_fit_params = {
'verbose': False
}
ctb_para = dict()
ctb_para['reg_params'] = ctb_reg_params
ctb_para['fit_params'] = ctb_fit_params
ctb_para['loss_func' ] = lambda y, pred: np.sqrt(mean_squared_error(y, pred))
def ctb_reg(self, para):
reg = ctb.CatBoostRegressor(**para['reg_params'])
reg.fit(x_train, y_train, **para['fit_params'])
pred = reg.predict(x_test)
loss = para['loss_func'](y_test, pred)
return {'loss': loss, 'status': STATUS_OK}
fmin(fn=ctb_reg, space=ctb_para, algo=tpe.suggest, max_evals=100, trials=Trials())
几分钟后,我得到了这个:
{'learning_rate': 4}
如何提取最佳学习率?是 np.arange(0.05, 0.31, 0.05)[4]
吗?有没有更好的提取方法?