Skip to main content

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 allows for sequential optimization, you can 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 allows you to optimize any scikit-learn compatible estimator class (e.g., SVC, XGBClassifier, GradientBoostingRegressor) hyperparameters efficiently by covering the search space more evenly than random search.

Installation

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

1. Basic Usage (Random Forest)

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
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)
optimizer.optimize(X, y, n_samples=8, batch_name="Batch 1")

# 5. Extend Optimization (Phase 2 - fills gaps in Phase 1)
optimizer.optimize(X, y, n_samples=8, batch_name="Batch 2")

# 6. Get Results
print(optimizer.get_best_params())
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

elementary_hpo-0.1.1.tar.gz (9.7 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.1.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file elementary_hpo-0.1.1.tar.gz.

File metadata

  • Download URL: elementary_hpo-0.1.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.0 Windows/10

File hashes

Hashes for elementary_hpo-0.1.1.tar.gz
Algorithm Hash digest
SHA256 cc3f5431cf83152fb37a44387f30969489cfbc4dc53b6fdf795d1b7d1c89b11e
MD5 d8ecace16340d73839caaae1cfd3d96f
BLAKE2b-256 d0f9646ff0de2f6893c3b374e548621cc5468b5f5cab6e065f955fa33b440e51

See more details on using hashes here.

File details

Details for the file elementary_hpo-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: elementary_hpo-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.0 Windows/10

File hashes

Hashes for elementary_hpo-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a3e8969e1959d4283fb47dbd335b33971e8f65dbc76204a7d012c4a9e289929c
MD5 a6bb3e2dfbf095f68ac5237af6ca6cb6
BLAKE2b-256 864946b2d78b0af4fdfaa36306a636bbe51976d743fc6f37e7ee95ed7931e0c4

See more details on using hashes here.

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