A lightweight hyperparameter optimization tool using Sobol sequences.
Project description
Elementary HPO
Elementary-hpo is a lightweight hyperparameter optimization library built on Sobol Sequences (Quasi-Monte Carlo methods).
It is designed to offer a mathematically superior alternative to Grid Search and Random Search by generating low-discrepancy sequences that cover the hyperparameter search space more evenly and efficiently. Unlike standard Random Search, elementary-hpo is sequential and deterministic, allowing you to pause a search, analyze results, and generate new hyperparameter candidates that mathematically fill the "gaps" of previous runs without redundancy.
Based on concepts discussed in the research paper Hyperparameter Optimization in Machine Learning, this package optimizes any scikit-learn compatible estimator (e.g., SVC, XGBClassifier, GradientBoostingRegressor).
🚀 Key Features
- Gap-Filling Strategy: Unlike Random Search, which can cluster points wastefully, Sobol sequences are designed to fill the empty spaces in your search grid progressively.
- Pause & Resume: Run a batch of 10 trials, check the results, and run 10 more. The optimizer remembers where it left off and continues exploring new areas of the hyperparameter space.
- Scikit-Learn Compatible: Works seamlessly with any estimator that follows the sklearn API.
- Lightweight: Minimal dependencies, focused purely on efficient parameter generation.
Installation
Using pip
pip install elementary-hpo
Using Poetry
If you are using Poetry for your project, add it as a dependency:
poetry add elementary-hpo
Quick Start
Basic Usage (Random Forest)
Here is a complete example of how to optimize a Random Forest classifier.
from sklearn.datasets import make_classification
from elementary_hpo import SobolOptimizer, plot_optimization_results, plot_space_coverage
# 1. Generate Data
X, y = make_classification(n_samples=1000, n_features=20, random_state=42)
# 2. Define Search Space
# Keys must match the estimator's parameter names
param_bounds = {
'n_estimators': (50, 300), # Integer tuple = Numerical range
'max_depth': (3, 20),
'min_samples_split': (0.01, 0.5), # Float tuple = Numerical range
'criterion': ['gini', 'entropy'] # List = Categorical choices
}
# 3. Initialize Optimizer
optimizer = SobolOptimizer(param_bounds)
# 4. Run Optimization (Phase 1)
# Optimizes a hypothetical estimator logic (or pass your actual model training function here)
optimizer.optimize(X, y, n_samples=8, batch_name="Batch 1")
# 5. Extend Optimization (Phase 2)
# This second run automatically detects the previous points and fills the "gaps"
optimizer.optimize(X, y, n_samples=8, batch_name="Batch 2")
# 6. Analyze Results
print("Best Parameters:", optimizer.get_best_params())
# Visualizations
plot_optimization_results(optimizer.results)
plot_space_coverage(optimizer.results, x_col="n_estimators", y_col="max_depth")
Citation
If you use this package, please consider citing the foundational paper:
"Hyperparameter Optimization in Machine Learning" (2024). arXiv:2410.22854. Available at: https://arxiv.org/abs/2410.22854
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
License
This project is licensed under the Apache License - see the LICENSE file for details.
Project details
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 elementary_hpo-0.2.0.tar.gz.
File metadata
- Download URL: elementary_hpo-0.2.0.tar.gz
- Upload date:
- Size: 10.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c1c7d4a37ec4f8e991ce50b9e62da584333f812632861291d0197860f6651717
|
|
| MD5 |
696afb0dbf45f5fc605acbed98726c30
|
|
| BLAKE2b-256 |
3e5b4d99761941298e7b14176dd6ea8a39542f44bd75e86af7918f4df4eb9e7b
|
Provenance
The following attestation bundles were made for elementary_hpo-0.2.0.tar.gz:
Publisher:
publish.yml on BetikuOluwatobi/elementary-hpo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
elementary_hpo-0.2.0.tar.gz -
Subject digest:
c1c7d4a37ec4f8e991ce50b9e62da584333f812632861291d0197860f6651717 - Sigstore transparency entry: 787092784
- Sigstore integration time:
-
Permalink:
BetikuOluwatobi/elementary-hpo@bbc09f5c57136fd71805bec8d794232ab5a94403 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/BetikuOluwatobi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbc09f5c57136fd71805bec8d794232ab5a94403 -
Trigger Event:
release
-
Statement type:
File details
Details for the file elementary_hpo-0.2.0-py3-none-any.whl.
File metadata
- Download URL: elementary_hpo-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ca7ac9884131925ac02de893e4ae37d218c44b442e779ce9e5eba9d6959e1b9
|
|
| MD5 |
5cb09b7505baea0229b9dd62b7f0901e
|
|
| BLAKE2b-256 |
841fba704531afc459e012aa5eade11b0e79aa0b915c4cae8c17c9afd68addb2
|
Provenance
The following attestation bundles were made for elementary_hpo-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on BetikuOluwatobi/elementary-hpo
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
elementary_hpo-0.2.0-py3-none-any.whl -
Subject digest:
7ca7ac9884131925ac02de893e4ae37d218c44b442e779ce9e5eba9d6959e1b9 - Sigstore transparency entry: 787092789
- Sigstore integration time:
-
Permalink:
BetikuOluwatobi/elementary-hpo@bbc09f5c57136fd71805bec8d794232ab5a94403 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/BetikuOluwatobi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bbc09f5c57136fd71805bec8d794232ab5a94403 -
Trigger Event:
release
-
Statement type: