Neural network surrogate hyperparameter optimization via a simple decorator
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mloopforml-1.0.0.tar.gz.
File metadata
- Download URL: mloopforml-1.0.0.tar.gz
- Upload date:
- Size: 94.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eec895510af95d5d51220c42d1d09f450ab02318800a49829183b26388446784
|
|
| MD5 |
b53b9ea5b8d7597362e4895e47e41855
|
|
| BLAKE2b-256 |
68f88357266a14a634e7adbf4e1763b3b9cd39b0b6dc34f9569becbe6134c98b
|
Provenance
The following attestation bundles were made for mloopforml-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on emv-dev/mloopforml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mloopforml-1.0.0.tar.gz -
Subject digest:
eec895510af95d5d51220c42d1d09f450ab02318800a49829183b26388446784 - Sigstore transparency entry: 1058323398
- Sigstore integration time:
-
Permalink:
emv-dev/mloopforml@9de0f610b43925843a95a6b2db490ee1b368e5e8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/emv-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@9de0f610b43925843a95a6b2db490ee1b368e5e8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mloopforml-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mloopforml-1.0.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5ecc506321c479811cea56ed83e5efe6616ea97c1db25f457107a065eda7409
|
|
| MD5 |
804552f168aa0ec1482119ef1b25fa80
|
|
| BLAKE2b-256 |
39f1aac10406f936db728349ce1c339bb2f254ca127592ffed75a4e405c20b6f
|
Provenance
The following attestation bundles were made for mloopforml-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on emv-dev/mloopforml
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mloopforml-1.0.0-py3-none-any.whl -
Subject digest:
e5ecc506321c479811cea56ed83e5efe6616ea97c1db25f457107a065eda7409 - Sigstore transparency entry: 1058323404
- Sigstore integration time:
-
Permalink:
emv-dev/mloopforml@9de0f610b43925843a95a6b2db490ee1b368e5e8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/emv-dev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@9de0f610b43925843a95a6b2db490ee1b368e5e8 -
Trigger Event:
push
-
Statement type: