Python hyperparameter optimization libraries

Updated Nov 2026

Python hyperparameter optimization libraries search for the training settings, such as learning rate and tree depth, that give a model its best validation score. A searcher proposes each new trial from the results of earlier trials rather than testing every combination. These libraries let machine learning teams tune models in fewer training runs.

Popularity

scikit-learn has the most monthly downloads in this comparison, at 214.9M, a count that covers all its machine learning work.

LibraryMonthly downloadsStarsLast releaseLicense
scikit-learn
214.9M
68.2KSep 2026BSD-3-Clause
Ray Tune
15.7M
44.3KNov 2026Apache-2.0
Optuna
14.5M
15.1KNov 2026MIT
Hyperopt
1.7M
7.6KJul 2026BSD-3-Clause
BayesianOptimization
843.0K
8.7KOct 2026MIT
scikit-optimize
609.1K
25Jun 2024BSD-3-Clause
Nevergrad
518.5K
4.2KApr 2025MIT
FLAML
361.1K
4.4KNov 2026MIT
Downloads: PyPI, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

Provides Python modules for machine learning and data mining.

Downloads / mo
214.9M
Stars
68.2K
Last release
1.9.1
License
BSD-3-Clause
$ pip install scikit-learn
from sklearn.datasets import load_iris
from sklearn.model_selection import GridSearchCV
from sklearn.svm import SVC

X, y = load_iris(return_X_y=True)
search = GridSearchCV(SVC(), {"C": [0.1, 1.0, 10.0]}, cv=3).fit(X, y)
print(search.best_params_)

scikit-learn examples

From open-source projects on GitHub

Runs experiments and hyperparameter-tuning trials with configurable searchers and schedulers.

Downloads / mo
15.7M
Stars
44.3K
Last release
2.60.0
License
Apache-2.0

Strengths

  • Schedules trials across machines. Run a hyperparameter sweep over a multi-node Ray cluster.
  • Stops underperforming trials early. Choose a trial scheduler that uses the reported training metric.

Limitations

  • Searchers restrict search-space expressions. Check the selected searcher’s support for lambdas and grid search.
  • Large search-space values add overhead. Pass large objects through with_parameters instead of the search space.

Quickstart

From index.html
$ pip install "ray[tune]"
from ray import tune

def objective(config):
    return {"loss": (config["x"] - 2) ** 2}

tuner = tune.Tuner(objective, param_space={"x": tune.grid_search([0, 1, 2])})
results = tuner.fit()
print(results.get_best_result(metric="loss", mode="min").config)

Ray Tune examples

From open-source projects on GitHub

Automates hyperparameter search with Python-defined spaces, samplers, and pruning.

Downloads / mo
14.5M
Stars
15.1K
Last release
5.1.0
License
MIT

Strengths

  • Defines spaces with Python branches. Suggest parameters inside conditionals and loops.
  • Prunes unpromising training trials. Report intermediate values and check should_prune during iterative training.

Limitations

  • Pruning targets single-objective studies. Use another stopping policy when optimizing multiple objectives.

Quickstart

From stable.md
$ pip install optuna
import optuna

def objective(trial):
    return (trial.suggest_float("x", -10, 10) - 2) ** 2

study = optuna.create_study(direction="minimize")
study.optimize(objective, n_trials=10)
print(study.best_params)

Optuna examples

From open-source projects on GitHub

Optimizes objective functions over stochastic search spaces, including conditional parameters.

Downloads / mo
1.7M
Stars
7.6K
Last release
0.3.0
License
BSD-3-Clause

Strengths

  • Encodes conditional parameter choices. Use nested choices to expose parameters only in the relevant branch.
  • Retains trial diagnostics. Return a dictionary with loss, status, and additional trial information.

Limitations

  • Spark trials fit single-machine models. Use another execution approach for models that need distributed training.
$ pip install hyperopt
from hyperopt import fmin, hp, tpe

best = fmin(lambda x: x ** 2, hp.uniform("x", -1, 1), algo=tpe.suggest, max_evals=10)
print(best)

Hyperopt examples

From open-source projects on GitHub

BayesianOptimization

Runs Bayesian optimization.

Downloads / mo
843.0K
Stars
8.7K
Last release
3.4.0
License
MIT

Quickstart

From basic-tour.html
$ pip install bayesian-optimization
from bayes_opt import BayesianOptimization

optimizer = BayesianOptimization(f=lambda x: -(x - 2) ** 2, pbounds={"x": (-5, 5)}, random_state=1)
optimizer.maximize(init_points=2, n_iter=3)
print(optimizer.max)

BayesianOptimization examples

From open-source projects on GitHub

scikit-optimize

Provides sequential model-based optimization for expensive or noisy black-box functions.

Downloads / mo
609.1K
Stars
25
Last release
0.10.2
License
BSD-3-Clause

Strengths

  • Fits scikit-learn search workflows. Use BayesSearchCV with an estimator’s existing fit and score methods.
  • Exposes a manual optimization loop. Use Optimizer ask and tell to control objective evaluation.

Limitations

  • Gradient methods need another optimizer. Use SciPy when gradients should drive the optimization.
  • Parallel search copies training data. Limit pre_dispatch when parallel parameter settings exceed available memory.

Quickstart

From README.rst
$ pip install scikit-optimize
from skopt import gp_minimize

result = gp_minimize(lambda x: x[0] ** 2, [(-1.0, 1.0)], n_calls=10, random_state=0)
print(result.x, result.fun)

scikit-optimize examples

From open-source projects on GitHub

Performs gradient-free optimization.

Downloads / mo
518.5K
Stars
4.2K
Last release
1.0.12
License
MIT

Quickstart

From optimization.html
$ pip install nevergrad
import nevergrad as ng

optimizer = ng.optimizers.NGOpt(parametrization=ng.p.Scalar(lower=-5, upper=5), budget=10)
recommendation = optimizer.minimize(lambda x: (x - 2) ** 2)
print(recommendation.value)

Nevergrad examples

From open-source projects on GitHub

Automates machine learning and tuning.

Downloads / mo
361.1K
Stars
4.4K
Last release
2.8.0
License
MIT

Quickstart

From README.md
$ pip install flaml
from flaml import tune

analysis = tune.run(
    lambda config: {"loss": config["x"] ** 2},
    config={"x": tune.uniform(-1, 1)}, metric="loss", mode="min",
    num_samples=10, use_ray=False,
)
print(analysis.best_config)

FLAML examples

From open-source projects on GitHub

FAQ

Optuna suits most tuning, with search spaces defined in Python, samplers, and pruning. Ray Tune suits distributed trials across a cluster. scikit-learn search classes suit grid and random search around its own estimators.

GridSearchCV is the scikit-learn class that tries every combination of listed parameter values with cross-validation. RandomizedSearchCV samples combinations instead of trying them all.

Optuna automates hyperparameter search with define-by-run objectives, conditional parameters, samplers, and pruning of weak trials.

Optuna defines the search space inside the objective function and prunes weak trials as they run. Hyperopt declares a stochastic search space up front and optimizes a single loss with TPE or random search.

BayesianOptimization maximizes a function with a Gaussian process over declared parameter bounds. scikit-optimize minimizes a function the same way and adds BayesSearchCV for scikit-learn estimators.

For coding agents

Found your hyperparameter optimization library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official