HyperParams#
- class openstef_core.mixins.predictor.HyperParams(**data: Any) None[source]
Bases:
BaseConfigBase configuration for model hyperparameters.
Serves as the foundation for model-specific hyperparameter configurations. Supports tuning ranges: pass a
FloatRange,IntRange, orCategoricalRangeas a field value at construction time and it will be extracted into_instance_rangeswhile the field keeps its declared default.Example
>>> from typing import Annotated >>> from openstef_core.mixins.param_ranges import FloatRange, IntRange >>> class MyHP(HyperParams): ... lr: Annotated[float, FloatRange(low=0.01, high=1.0)] = 0.3 ... depth: Annotated[int, IntRange(low=1, high=15)] = 6 >>> hp = MyHP(lr=FloatRange(low=0.001, high=0.5, tune=True)) >>> hp.lr # field keeps its default 0.3 >>> hp.get_search_space() # extracted range {'lr': FloatRange(low=0.001, high=0.5, log=False, tune=True)}
- Parameters:
data (
Any)
- get_search_space(include: set[str] | None = None) dict[str, TuningRange][source]
Merge instance and class-level ranges, returning only
tune=Truefields.
- get_tuning_overrides() dict[str, TuningRange][source]
Return the unresolved range overrides that were passed at construction time.
- clear_tuning_ranges() Self[source]
Clear any stored tuning range overrides from this hyperparameter config.
- Return type:
Self- Returns:
selfwith_instance_rangescleared.
- materialize(update: dict[str, Any] | None = None) Self[source]
Return a copy with concrete values only and no stored tuning ranges.
- model_config: ClassVar[ConfigDict] = {'arbitrary_types_allowed': False, 'extra': 'ignore', 'protected_namespaces': ()}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].