Optuna is a model-agnostic Bayesian optimization library for 01 Python. It can optimize any function of the form
def optimize_thing(trial: optuna.Trial) -> float:
loss = thing_to_optimize(
param_1 = trial.suggest_int('param_1', low, high),
param_2 = trial.suggest_float('param_2', low, high),
...
)
return lossThe arguments to suggest_X are the parameter name, the minimum value (inclusive) and the maximum value (exclusive by default).
This is optimized by statements of the form
study = optuna.create_study(direction="minimize")
study.optimize(optimize_thing, n_trials=100)Optuna is an excellent choice for hyperparameter tuning.