mloopforml
Neural network surrogate hyperparameter optimization via a simple decorator.
Install
pip install mloopforml
Quickstart
import mloopforml as mloop
@mloop.optimize(
params={"lr": (1e-4, 1e-1), "dropout": (0.0, 0.5)},
max_iterations=50,
direction="minimize", # or "maximize"
seed=42,
)
def train(lr, dropout):
# Replace with your actual training loop
# Return a single float (lower is better when direction="minimize")
loss = some_model.train(lr=lr, dropout=dropout)
return loss
result = train()
print(result.best_params) # {'lr': 0.0042, 'dropout': 0.12}
print(result.best_score) # 0.237
mloopforml uses M-LOOP's neural network surrogate to propose new parameter combinations. The decorator handles the optimization loop — your function just returns a number.
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
params |
dict[str, (float, float)] |
required | Hyperparameter name → (min, max) bounds |
max_iterations |
int |
50 |
Total number of trials |
direction |
str |
"minimize" |
"minimize" or "maximize" |
num_training_runs |
int |
1 |
Bootstrap trials before the NN surrogate activates |
seed |
int | None |
None |
Random seed for reproducible runs |
Result
Calling the decorated function returns an OptimizeResult:
result.best_params # dict[str, float] — best parameter combination found
result.best_score # float — best objective value
result.all_params # list[dict] — all trial params, in order
result.all_costs # list[float] — all trial scores (nan for failed trials)
Requirements
- Python >=3.11
- numpy >=2.0
- scipy >=1.15
License
MIT
Metadata
Release files for mloopforml 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mloopforml-1.0.0.tar.gz | 94.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mloopforml-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 102.8 kB
Release files / mloopforml-1.0.0.tar.gz
| Download URL | mloopforml-1.0.0.tar.gz |
|---|---|
| Size | 94.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eec895510af95d5d51220c42d1d09f450ab02318800a49829183b26388446784
|
|
BLAKE2b-256 checksum How to use checksums |
68f88357266a14a634e7adbf4e1763b3b9cd39b0b6dc34f9569becbe6134c98b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 7, 2026.
Transparency logRelease files / mloopforml-1.0.0-py3-none-any.whl
| Download URL | mloopforml-1.0.0-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e5ecc506321c479811cea56ed83e5efe6616ea97c1db25f457107a065eda7409
|
|
BLAKE2b-256 checksum How to use checksums |
39f1aac10406f936db728349ce1c339bb2f254ca127592ffed75a4e405c20b6f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Mar 7, 2026.
Transparency log