Skip to main content

meta-hpo

CI PyPI License: MIT Python

Metaheuristic hyperparameter optimization for Python, with a small numpy core.

You describe a search space and a function that trains your model and returns a score. meta-hpo searches for the parameters that maximise or minimise that score. The first optimizer is the Artificial Bee Colony (ABC); more metaheuristics will follow behind the same interface.

Installation

pip install meta-hpo

meta-hpo needs Python 3.10+ and numpy.

Quick start

import metahpo as mh

space = mh.Space(
    {
        "lr": mh.Float(1e-4, 1e-2, log=True),
        "kernel": mh.Categorical([3, 5, 7]),
        "units": mh.Int(16, 256),
        "dropout": mh.Float(0.0, 0.5),
    }
)


def train(params):
    model = build_model(params["kernel"], params["units"], params["dropout"])
    return fit_and_score(model, lr=params["lr"])


study = mh.optimize(train, space, direction="max", max_evals=300, seed=1)
print(study.best_params, study.best_score)

train can do anything: a Keras or PyTorch training run, cross-validation, an F1 score. Its training budget is entirely yours; meta-hpo only counts evaluations.

Ask and tell

For full control over where and how candidates are evaluated:

opt = mh.ABCOptimizer(space, direction="max", colony_size=10, limit=15, seed=1)

for _ in range(300):
    candidates = opt.ask()
    opt.tell(candidates, [train(c.params) for c in candidates])

print(opt.best_params, opt.best_score)

Search space

Parameter Values Example
Float(low, high, log=False) real numbers in [low, high] Float(1e-4, 1e-2, log=True)
Int(low, high, log=False) integers low..high, inclusive Int(16, 256)
Categorical(choices) one of choices Categorical(["relu", "tanh"])

Optimizers search the unit cube [0, 1]^d; the space maps each point to typed parameters.

Behaviour

  • A score of NaN or infinity counts as the worst possible value for the chosen direction.
  • With cache=True (the default), a repeated parameter set reuses its earlier score instead of training again.
  • The same seed reproduces the same search.

Contributing

See CONTRIBUTING.md. Changes are listed in CHANGELOG.md.

License

MIT

Metadata

Release files for meta-hpo 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for meta-hpo 0.1.0
File Size Uploaded Provenance Actions
meta_hpo-0.1.0.tar.gz 329.5 kB With provenance Details for meta_hpo-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for meta-hpo 0.1.0
File Interpreter ABI Platform Actions
meta_hpo-0.1.0-py3-none-any.whl Python 3 none any Details for meta_hpo-0.1.0-py3-none-any.whl

Total release size: 342.6 kB

Release files / meta_hpo-0.1.0.tar.gz

Download URL meta_hpo-0.1.0.tar.gz
Size 329.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7f6ad9fc508f7e33ece65a4290e700f9d6232b837ef360b56fea6f34a7f94cde
BLAKE2b-256 checksum
How to use checksums
8e8ba0f17e2fc999fed7837718013de0d2eca803fbbae1f531089f8c7cf2a4e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / meta_hpo-0.1.0-py3-none-any.whl

Download URL meta_hpo-0.1.0-py3-none-any.whl
Size 13.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e5c95fb41907c2ec527aec8a2afbe4d69a2bc0236cb165004d074d9f3386eba
BLAKE2b-256 checksum
How to use checksums
b481b0f4c07a09cc45e66fd570005cc00e6a37b8f51376a76a84c32c49d7655d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for meta-hpo 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for meta_hpo-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page