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 and does not count against max_evals.
  • 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.2.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.2.0
File Size Uploaded Provenance Actions
meta_hpo-0.2.0.tar.gz 336.7 kB With provenance Details for meta_hpo-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 350.6 kB

Release files / meta_hpo-0.2.0.tar.gz

Download URL meta_hpo-0.2.0.tar.gz
Size 336.7 kB
Tags Source
SHA-256 checksum
How to use checksums
d5cd77aaf00b74cdff5007a62f286c077de1c2dde580cd5e410d882575ea0cd0
BLAKE2b-256 checksum
How to use checksums
ced8a93955a6e96494365aab7036582ceab1dc4b033bfe148b0a0fba433f0a5d
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.2.0-py3-none-any.whl

Download URL meta_hpo-0.2.0-py3-none-any.whl
Size 13.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
252bcedd1cde66c24007ec880c9b510a55a988bc654c63e458f8af34cbb5394b
BLAKE2b-256 checksum
How to use checksums
76402aa6df582d141840ec4b6e2a45a1b1d94a932e05ae08ead6044d1cc2370d
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.2.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.2.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