hpt
A minimal hyperparameter tuning framework to help you train hundreds of models.
It's essentially a set of helpful wrappers over optuna.
Consult the package documentation here!
Install
Install package from PyPI:
pip install hyperparameter-tuning
Getting started
from hpt.tuner import ObjectiveFunction, OptunaTuner
obj_func = ObjectiveFunction(
X_train, y_train, X_test, y_test,
hyperparameter_space=HYPERPARAM_SPACE_PATH, # path to YAML file
eval_metric="accuracy",
s_train=s_train,
s_val=s_test,
threshold=0.50,
)
tuner = OptunaTuner(
objective_function=obj_func,
direction="maximize", # NOTE: can pass other useful study kwargs here (e.g. storage)
)
# Then just run optimize as you would for an optuna.Study object
tuner.optimize(n_trials=20, n_jobs=4)
# Results are stored in tuner.results
tuner.results
# You can reconstruct the best predictor with:
clf = obj_func.reconstruct_model(obj_func.best_trial)
Defining a hyperparameter space
The hyperparameter space is provided either path to a YAML file, or as a dict
with the same structure.
Example hyperparameter spaces here.
The YAML file must follow this structure:
# One or more top-level algorithms
DT:
# Full classpath of algorithm's constructor
classpath: sklearn.tree.DecisionTreeClassifier
# One or more key-word arguments to be passed to the constructor
kwargs:
# Kwargs may be sampled from a distribution
max_depth:
type: int # either 'int' or 'float'
range: [ 10, 100 ] # minimum and maximum values
log: True # (optionally) whether to use logarithmic scale
# Kwargs may be sampled from a fixed set of categories
criterion:
- 'gini'
- 'entropy'
# Kwargs may be a pre-defined value
min_samples_split: 4
# You may explore multiple algorithms at once
LR:
classpath: sklearn.linear_model.LogisticRegression
kwargs:
# An example of a float hyperparameter
C:
type: float
range: [ 0.01, 1.0 ]
log: True
Metadata
Release files for hyperparameter-tuning 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hyperparameter_tuning-0.3.2.tar.gz | 24.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hyperparameter_tuning-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 50.6 kB
Release files / hyperparameter_tuning-0.3.2.tar.gz
| Download URL | hyperparameter_tuning-0.3.2.tar.gz |
|---|---|
| Size | 24.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
673abb105aaf90c134e26a4d6a1fdd3ee22d1b4fff1d89522e088e2826a030bf
|
|
BLAKE2b-256 checksum How to use checksums |
647fd84c70259184ba5c8d7a8cda7a514896065f673329bc53ecf7e38eab0633
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Release files / hyperparameter_tuning-0.3.2-py3-none-any.whl
| Download URL | hyperparameter_tuning-0.3.2-py3-none-any.whl |
|---|---|
| Size | 26.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
71939a31108774b2933c3d19bea4512962a4c72f99bf4f922d0f35252e72467f
|
|
BLAKE2b-256 checksum How to use checksums |
a766450903183e0f44aca23ebc4f3b1679770571fee65b1feea661deef9eb5b6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.20
|
Security for hyperparameter-tuning 0.3.2
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.