Hyperopt is a Python library for distributed and asynchronous hyperparameter optimization over complex search spaces.
Distributed Asynchronous Hyperparameter Optimization in Python
This tool is primarily used by data scientists and machine learning engineers to efficiently tune hyperparameters of AI models, improving model performance through automated search. It supports both serial and parallel optimization, making it suitable for scalable and distributed environments.
For best results, define search spaces carefully to reflect the problem domain. Use virtual environments to manage dependencies. The tool supports distributed trials via MongoTrials and SparkTrials for scalable optimization. Code formatting with Black and pre-commit hooks is recommended for contributions.
pip install hyperopt
git clone https://github.com/<github username>/hyperopt.git
cd hyperopt
python3 -m venv my_env or python -m venv my_env or conda create -n my_env python=3
source my_env/bin/activate or conda activate my_env
pip install -e '.[MongoTrials, SparkTrials, ATPE, dev]' (Linux/UNIX) or pip install -e .[MongoTrials], pip install -e .[SparkTrials], pip install -e .[ATPE], pip install -e .[dev] (Windows)
git remote add upstream https://github.com/hyperopt/hyperopt.git
git checkout master
git pull upstream master
git checkout -b my_feature
pip install hyperopt
Installs the hyperopt library from PyPI.
from hyperopt import fmin, tpe, hp, space_eval
Imports core functions for defining search spaces and running optimization.
best = fmin(objective, space, algo=tpe.suggest, max_evals=100)
Runs the hyperparameter optimization minimizing the objective function over the defined search space using the TPE algorithm.
print(best)
Outputs the best hyperparameter configuration found.
print(space_eval(space, best))
Evaluates and prints the best hyperparameter values in the original search space format.
git clone https://github.com/<github username>/hyperopt.git
Clones a forked copy of the hyperopt repository to local disk for development.
pip install -e '.[MongoTrials, SparkTrials, ATPE, dev]'
Installs hyperopt with extra dependencies needed for testing and extended functionality.