Hyperactive

A unified interface for optimization algorithms and experiments

Tests Coverage


Hyperactive provides a collection of optimization algorithms, accessible through a unified experiment-based interface that separates optimization problems from algorithms. The library provides native implementations of algorithms from the Gradient-Free-Optimizers package alongside direct interfaces to Optuna and scikit-learn optimizers.

Features#

What makes Hyperactive stand out for optimization tasks.

20+ Optimization Algorithms

From Hill Climbing to Bayesian Optimization, Particle Swarm, Genetic Algorithms, and more.

Direct ML Integration

First-class support for scikit-learn, sktime, skpro, and PyTorch. Tune models with minimal code changes.

Experiment Abstraction

Clean separation between what to optimize (experiments) and how to optimize (algorithms).

3 Optimizer Backends

Native GFO algorithms, Optuna samplers, and scikit-learn search methods through one unified API.

Mixed Parameter Spaces

Categorical, integer, and continuous parameters. Define search spaces with NumPy arrays or lists.

Stable Since 2019

5+ years of development, comprehensive test coverage, and active maintenance.


Optimization Backends#

Hyperactive provides a unified interface to three powerful optimization backends. Choose the one that best fits your needs, or switch between them effortlessly.

The native backend with 20 optimization algorithms implemented from scratch. Ideal for custom objective functions and research applications.

  • Hill Climbing variants

  • Simulated Annealing

  • Particle Swarm & Genetic Algorithms

  • Bayesian Optimization

  • And 15+ more algorithms

Industry-standard hyperparameter optimization framework with state-of-the-art samplers and pruning strategies.

  • Tree-Parzen Estimator (TPE)

  • CMA-ES for continuous spaces

  • Gaussian Process optimization

  • Multi-objective (NSGA-II/III)

  • Native continuous parameter support

Familiar scikit-learn search interfaces with enhanced integration for cross-validation experiments.

  • GridSearchCV

  • RandomizedSearchCV

  • HalvingGridSearchCV

  • HalvingRandomSearchCV

  • Drop-in sklearn compatibility


Integrations#

Hyperactive works seamlessly with popular machine learning frameworks.


Quick Install#

PyPI Version Python Versions License

$ pip install hyperactive
$ pip install hyperactive[all_extras]
$ pip install hyperactive[sklearn-integration]
$ pip install hyperactive[sktime-integration]

Quick Example#

Get started in just a few lines of code:

import numpy as np

from hyperactive.opt.gfo import HillClimbing


# Define your objective function
def objective(params):
    x, y = params["x"], params["y"]
    return -(x**2 + y**2)  # Maximize (minimize negative)


# Define the search space
search_space = {
    "x": np.arange(-5, 5, 0.1),
    "y": np.arange(-5, 5, 0.1),
}

# Create optimizer and solve
optimizer = HillClimbing(
    search_space=search_space,
    n_iter=5,
    experiment=objective,
)
best_params = optimizer.solve()
print(f"Best parameters: {best_params}")
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC

from hyperactive.integrations.sklearn import OptCV
from hyperactive.opt.gfo import HillClimbing

# Load data
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y)

# Define optimizer with search space
search_space = {"kernel": ["linear", "rbf"], "C": [0.1, 1, 10]}
optimizer = HillClimbing(search_space=search_space, n_iter=5)

# Create tuned estimator and fit
tuned_svc = OptCV(SVC(), optimizer)
tuned_svc.fit(X_train, y_train)

print(f"Best params: {tuned_svc.best_params_}")
import numpy as np

from hyperactive.opt.gfo import BayesianOptimizer


def complex_objective(params):
    x = params["x"]
    y = params["y"]
    return -((x - 2) ** 2 + (y + 1) ** 2) + np.sin(x * y)


search_space = {
    "x": np.linspace(-5, 5, 100),
    "y": np.linspace(-5, 5, 100),
}

optimizer = BayesianOptimizer(
    search_space=search_space,
    n_iter=5,
    experiment=complex_objective,
)
best_params = optimizer.solve()

Contents#