Skip to main content

A lightweight hyperparameter optimization tool using Sobol sequences.

Project description

Elementary HPO

PyPI version Python Versions Downloads Monthly Downloads License

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.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. 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

elementary_hpo-0.2.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elementary_hpo-0.2.0-py3-none-any.whl (11.9 kB view details)

Uploaded Python 3

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

Hashes for elementary_hpo-0.2.0.tar.gz
Algorithm Hash digest
SHA256 c1c7d4a37ec4f8e991ce50b9e62da584333f812632861291d0197860f6651717
MD5 696afb0dbf45f5fc605acbed98726c30
BLAKE2b-256 3e5b4d99761941298e7b14176dd6ea8a39542f44bd75e86af7918f4df4eb9e7b

See more details on using hashes here.

Provenance

The following attestation bundles were made for elementary_hpo-0.2.0.tar.gz:

Publisher: publish.yml on BetikuOluwatobi/elementary-hpo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for elementary_hpo-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca7ac9884131925ac02de893e4ae37d218c44b442e779ce9e5eba9d6959e1b9
MD5 5cb09b7505baea0229b9dd62b7f0901e
BLAKE2b-256 841fba704531afc459e012aa5eade11b0e79aa0b915c4cae8c17c9afd68addb2

See more details on using hashes here.

Provenance

The following attestation bundles were made for elementary_hpo-0.2.0-py3-none-any.whl:

Publisher: publish.yml on BetikuOluwatobi/elementary-hpo

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page