tempor.automl.pipeline_selector module¶
Module with pipeline selector helper class for AutoML.
- tempor.automl.pipeline_selector.get_fqn(prefix: str, name: str) str[source]¶
Return a full plugin name from category / task type prefix and plugin name, that is
{prefix}.{name}.
-
class tempor.automl.pipeline_selector.PipelineSelector(task_type: Literal[prediction.one_off.classification] | Literal[prediction.one_off.regression] | Literal[prediction.temporal.classification] | Literal[prediction.temporal.regression] | Literal[time_to_event] | Literal[treatments.one_off.classification] | Literal[treatments.one_off.regression] | Literal[treatments.temporal.classification] | Literal[treatments.temporal.regression], predictor: str, static_imputers: list[str] =
['static_tabular_imputer'], static_scalers: list[str] =['static_standard_scaler', 'static_minmax_scaler'], temporal_imputers: list[str] =['bfill', 'ts_tabular_imputer', 'ffill'], temporal_scalers: list[str] =['ts_minmax_scaler', 'ts_standard_scaler'])[source]¶ Bases:
objectA helper class for AutoML pipeline selection.
- Defines custom version of methods:
hyperparameter_space,sample_hyperparameters.
- Adds methods to create a pipeline from sampled hyperparameters:
pipeline_class_from_hps,pipeline_from_hps.
Provides the tools to create candidate pipelines where the imputers / scalers are exposed as a categorical hyperparameter in the hyperparameter space. The hyperparameter space of these, and the final predictor step are also sampled.
- Parameters:¶
- task_type : PredictiveTaskType¶
The task type of the predictors.
- predictor : str¶
The predictor estimator to be used as the last stage of the pipelines.
- static_imputers : List[str], optional¶
A list of candidate static imputers. Defaults to
DEFAULT_STATIC_IMPUTERS.- static_scalers : List[str], optional¶
A list of candidate static scalers. Defaults to
DEFAULT_STATIC_SCALERS.- temporal_imputers : List[str], optional¶
A list of candidate temporal imputers. Defaults to
DEFAULT_TEMPORAL_IMPUTERS.- temporal_scalers : List[str], optional¶
A list of candidate temporal scalers. Defaults to
DEFAULT_TEMPORAL_SCALERS.
- static format_hps_names(plugin: Any, hps: list[Params]) list[Params][source]¶
Format hyperparameter space of a plugin by giving each
Paramname as[plugin.name](hyperparameter.name). Necessary for differentiating hyperparameters of different stages in the pipeline.
-
hyperparameter_space(*args: Any, override: list[Params] | None =
None, **kwargs: Any) list[Params][source]¶ The customized
hyperparameter_spaceimplementation. The hyperparameter space is built up of the hyperparameters of each pipeline steps (the preprocessors, and the final predictive step).CategoricalParamsfor choosing which preprocessor to use are also added (if at least onestatic_imputer, … are provided). Parameter names are customized to be able to differentiate pipeline stages (seeformat_hps_names).- Parameters:¶
- *args : Any
Arguments to be passed on to the
hyperparameter_spacemethods of the pipeline steps.- override : Optional[List[Params]], optional¶
Hyperparameter space override for the final predictive step of the pipeline. Defaults to
None.- **kwargs : Any
Keyword arguments to be passed on to the
hyperparameter_spacemethods of the pipeline steps.
- Returns:¶
Returned hyperparameter space.
- Return type:¶
List[Params]
-
sample_hyperparameters(*args: Any, override: list[Params] | None =
None, **kwargs: Any) dict[str, Any][source]¶ The customized
sample_hyperparametersimplementation. Uses the customizedhyperparameter_space.- Parameters:¶
- *args : Any
Arguments to be passed on to the
hyperparameter_spacemethods of the pipeline steps.- override : Optional[List[Params]], optional¶
Hyperparameter space override for the final predictive step of the pipeline. Defaults to
None.- **kwargs : Any
Keyword arguments to be passed on to the
hyperparameter_spacemethods of the pipeline steps.
- Returns:¶
Sampled hyperparameters dictionary.
- Return type:¶
Dict[str, Any]