Add your description here
Project description
SpotOptim
Sequential Parameter Optimization with Bayesian Optimization.
Features
- Bayesian Optimization: Uses surrogate models to efficiently optimize expensive black-box functions
- Multiple Acquisition Functions: Expected Improvement (EI), Predicted Mean (y), Probability of Improvement (PI)
- Flexible Surrogates: Default Gaussian Process or custom Kriging surrogate
- Variable Types: Support for continuous, integer, and mixed variable types
- scipy-compatible: Returns OptimizeResult objects compatible with scipy.optimize
Installation
pip install spotoptim
Quick Start
import numpy as np
from spotoptim import SpotOptim
# Define objective function
def rosenbrock(X):
X = np.atleast_2d(X)
x, y = X[:, 0], X[:, 1]
return (1 - x)**2 + 100 * (y - x**2)**2
# Set up optimization
bounds = [(-2, 2), (-2, 2)]
optimizer = SpotOptim(
fun=rosenbrock,
bounds=bounds,
max_iter=50,
n_initial=10,
seed=42
)
# Run optimization
result = optimizer.optimize()
print(f"Best point: {result.x}")
print(f"Best value: {result.fun}")
Using Kriging Surrogate
SpotOptim includes a simplified Kriging (Gaussian Process) surrogate as an alternative to scikit-learn's GaussianProcessRegressor:
from spotoptim import SpotOptim, Kriging
# Create Kriging surrogate
kriging = Kriging(
noise=1e-6,
min_theta=-3.0,
max_theta=2.0,
seed=42
)
# Use with SpotOptim
optimizer = SpotOptim(
fun=rosenbrock,
bounds=bounds,
surrogate=kriging, # Use Kriging instead of default GP
seed=42
)
result = optimizer.optimize()
API Reference
SpotOptim
Parameters:
fun(callable): Objective function to minimizebounds(list of tuples): Bounds for each dimension as [(low, high), ...]max_iter(int, default=20): Maximum number of optimization iterationsn_initial(int, default=10): Number of initial design pointssurrogate(object, optional): Surrogate model (default: GaussianProcessRegressor)acquisition(str, default='ei'): Acquisition function ('ei', 'y', 'pi')var_type(list of str, optional): Variable types for each dimensiontolerance_x(float, optional): Minimum distance between pointsseed(int, optional): Random seed for reproducibilityverbose(bool, default=False): Print progress information
Methods:
optimize(X0=None): Run optimization, optionally with initial design points
Kriging
Parameters:
noise(float, optional): Regularization parameterkernel(str, default='gauss'): Kernel typen_theta(int, optional): Number of theta parametersmin_theta(float, default=-3.0): Minimum log10(theta) boundmax_theta(float, default=2.0): Maximum log10(theta) boundseed(int, optional): Random seed
Methods:
fit(X, y): Fit the model to training datapredict(X, return_std=False): Predict at new points
Examples
See the notebooks/demos.ipynb for comprehensive examples including:
- 2D Rosenbrock function optimization
- 6D Rosenbrock with budget constraints
- Using Kriging surrogate vs default GP
Development
# Clone repository
git clone https://github.com/sequential-parameter-optimization/spotoptim.git
cd spotoptim
# Install with uv
uv pip install -e .
# Run tests
uv run pytest tests/
# Build package
uv build
License
See LICENSE file.
References
Based on the SPOT (Sequential Parameter Optimization Toolbox) methodology.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spotoptim-0.0.5.tar.gz.
File metadata
- Download URL: spotoptim-0.0.5.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e38fd3a5e202f62d0dd01453a27c9ac591465d94547d3c18a075f65d86bb6d3
|
|
| MD5 |
18b6339ecc236fd3b3aaeeb4accaa449
|
|
| BLAKE2b-256 |
975f683d8ac902d017474a70697e47fed57e7a02dbe4007856c44818b7dc69e7
|
File details
Details for the file spotoptim-0.0.5-py3-none-any.whl.
File metadata
- Download URL: spotoptim-0.0.5-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
930f7c8e4b63ff9d4eb394cdde45dd6fe017e3030bed009e263fa14e010d4f48
|
|
| MD5 |
800b650865f2b2d76ad04eeedbedf35e
|
|
| BLAKE2b-256 |
7eeca486686acb3003c27f095e342e3c31d7efd853eef5efc772f82e48dd054b
|