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.0.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.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: elementary_hpo-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 6a2a5d747e36ce68190121ed5f40ba5793e8adaa48abc56d5624c1b78a2cd954
MD5 9deda5187b6975054e06a31bfce76f59
BLAKE2b-256 1caa3c67a84e4ee4bc62db67f1bfe10056ee0f730442621f93cf806692781b23

See more details on using hashes here.

File details

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

File metadata

  • Download URL: elementary_hpo-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad276fc57b85ddc152d95e05616c8bfe63e78eecf36b98d3b3bc0206ffd6c30f
MD5 906a1d574480041c3ecc087c37ba4c30
BLAKE2b-256 0c1179c3cfb893f8b8467e3210aa449bd52cc7c57f6f71df6e1fac26ab37392b

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