hyperopt / hyperopt-sklearn

Hyper-parameter optimization for sklearn
hyperopt.github.io/hyperopt-sklearn
Other
1.57k stars 270 forks source link

gradient_boosting_regressor loss #203

Closed MarkBusschers closed 8 months ago

MarkBusschers commented 8 months ago

Hello, I'm trying to define the following HyperoptEstimator:

estim = HyperoptEstimator( regressor = gradient_boosting_regressor( "gbr", alpha=quantile, loss="quantile", n_estimators=hp.choice('n_estimators', list(np.arange(20, 80, 1, dtype=int))), min_samples_leaf = hp.choice('min_samples', list(np.arange(10, 50, 1, dtype=int))), max_features = hp.choice('max_features', list(np.arange(2, 10, 1, dtype=int))), max_depth = hp.choice('max_depth', list(np.arange(2, 10, 1, dtype=int))), min_samples_split = hp.choice('min_samples_split', list(np.arange(2, 50, 1, dtype=int))), ), verbose=True, algo=tpe.suggest, max_evals=10, trial_timeout=30, )

This returns the folowing error: Invalid parameter 'loss' with value 'quantile'. Choose 'squared_error', 'absolute_error', 'huber' or 'quantile'

I think the following piece of code should be changed:

@validate(params=["loss"], validation_test=lambda param: not isinstance(param, str) or param in ("squared_error", "absolute_error", "huber" or "quantile"), msg="Invalid parameter '%s' with value '%s'. " "Choose 'squared_error', 'absolute_error', 'huber' or 'quantile'.")

To:

@validate(params=["loss"], validation_test=lambda param: not isinstance(param, str) or param in ("squared_error", "absolute_error", "huber", "quantile"), msg="Invalid parameter '%s' with value '%s'. " "Choose 'squared_error', 'absolute_error', 'huber' or 'quantile'.")

mandjevant commented 8 months ago

Good catch. Thank you for reporting this.