src.core.helpers
- parse_hyperparameters_from_dict(items)
Convert a raw hyperparameter specification dict into a mapping of
Hyperparameterobjects.- Parameters:
items (dict[str, Any]) – Mapping of hyperparameter name to its specification.
- Returns:
Parsed hyperparameters keyed by name.
- Return type:
dict[str, Hyperparameter]
- Raises:
ValueError – If a specification is malformed or an unsupported type is encountered.
Supported specification formats
Python value
Produced type
Notes
int,float,strConstantFixed value; not searched.
(lower, upper)tupleUniformFloatHyperparameterorUniformIntegerHyperparameterType inferred from bounds:
float→ Float HP,int→ Int HP.[choice1, choice2, …]listCategoricalHyperparameterFirst element used as default unless overridden.
{"val": …, "default": …, "log": …}dictSame as above, extended format
"val"is required;"default"and"log"are optional."log": Trueenables log-scale sampling for numeric ranges.HyperparameterinstancePassed through unchanged
Allows mixing raw specs and pre-built ConfigSpace objects.
Example
from src.core.helpers import parse_hyperparameters_from_dict specs = { "lr": {"val": (1e-4, 0.1), "default": 0.01, "log": True}, "margin": {"val": [0.6, 0.8, 1.0], "default": 1.0}, "dropout": 0.5, "epochs": (10, 100), } hps = parse_hyperparameters_from_dict(specs) # hps["lr"] → UniformFloatHyperparameter (log-scale) # hps["margin"] → CategoricalHyperparameter # hps["dropout"] → Constant(0.5) # hps["epochs"] → UniformIntegerHyperparameter
Extended dict format
The
{"val": …}dict format gives you fine-grained control:# YAML equivalent used in AutoMAX config files optimizer_kwargs: lr: val: [0.0001, 0.1] default: 0.01 log: true margin: val: [0.6, 0.8, 1.0] default: 1.0
Note
If both
"log": trueand a list-of-choicesvalare supplied, thelogflag is silently ignored (categorical HPs have no log-scale concept).