A minimal framework for running hyperparameter tuning
Project description
hpt
This repository is under construction :construction:
A minimal hyperparameter tuning framework to help you train hundreds of models.
It's essentially a set of helpful wrappers over optuna.
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,
eval_metric='accuracy',
s_train=s_train,
s_val=s_test,
threshold=0.50,
)
tuner = OptunaTuner(obj_func) # 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
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 and
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
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
Close
Hashes for hyperparameter-tuning-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1486fcb72d63f278c3b26eb39e2b5de4d41ff5148afee8ac4c88f5b364662ca3 |
|
MD5 | 1713f2f7f366de23d0b73a448b181552 |
|
BLAKE2b-256 | e30529e975ff89a06612c8cd3f7d919aac9432eaa4025cc94475bbcbc3fcbcd6 |
Close
Hashes for hyperparameter_tuning-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1d0f6ee416e64edd39e3eead74e80be06f706026e9eb17403236c963ba54eb9 |
|
MD5 | fb29b7168d77cd7b2d4fd2b24d7046af |
|
BLAKE2b-256 | a9e31eae1ed1f9a4554d8ac4f35564c417a78539229f0558585e3afae7cfa9e2 |