tempor.methods.pipeline package¶
Submodules¶
Module contents¶
A package directory for the pipeline functionality.
-
class tempor.methods.pipeline.PipelineBase(plugin_params: dict[str, dict] | None =
None, **kwargs: Any)[source]¶ Bases:
objectInstantiate the pipeline, (optionally) providing initialization parameters for constituent step plugins.
Note
The implementations of the methods on this class (
fit,sample_hyperparameters, etc.) are auto-generated by thePipelineMetametaclass.- Parameters:¶
- static pipeline_seq(*args: Any) str[source]¶
Get a string representation of the pipeline, stating each stage plugin, e.g. like:
'preprocessing.imputation.temporal.bfill->...->prediction.one_off.classification.nn_classifier'
- static hyperparameter_space(*args: Any, **kwargs: Any) dict[str, list[Params]][source]¶
The pipeline version of the estimator static method of the same name. All the hyperparameters of the different stages will be returned.
- static hyperparameter_space_for_step(name: str, *args: Any, **kwargs: Any) list[Params][source]¶
Return the hyperparameter space (
List[Params]) for the step of the pipeline as specified byname.
-
classmethod sample_hyperparameters(*args: Any, override: list[Params] | None =
None, **kwargs: Any) dict[str, Any][source]¶ The pipeline version of the estimator method of the same name. Returns a hyperparameter sample.
- fit(data: BaseDataset, *args: Any, **kwargs: Any) Self[source]¶
The pipeline version of the estimator
fitmethod.By analogy to
sklearn, under the hood,fit_transformwill be called on all the pipeline steps except for the last one (the transformer steps of the pipeline), andfitwill be called on the last step (the predictive step of the pipeline).- Parameters:¶
- data : dataset.BaseDataset¶
Input dataset.
- *args : Any
Any positional arguments.
- **kwargs : Any
Any keyword arguments.
- Returns:¶
Returns the fitted pipeline itself.
- Return type:¶
Self
- predict(data: PredictiveDataset, *args: Any, **kwargs: Any) Any[source]¶
The pipeline version of the estimator
predictmethod. Applicable if the final step of the pipeline has apredictmethod implemented.- Parameters:¶
- data : dataset.PredictiveDataset¶
Input dataset.
- *args : Any
Any positional arguments.
- **kwargs : Any
Any keyword arguments.
- Returns:¶
the same return type as the final step of the pipeline.
- Return type:¶
Any
- predict_proba(data: PredictiveDataset, *args: Any, **kwargs: Any) Any[source]¶
The pipeline version of the estimator
predict_probamethod. Applicable if the final step of the pipeline has apredict_probamethod implemented.- Parameters:¶
- data : dataset.PredictiveDataset¶
Input dataset.
- *args : Any
Any positional arguments.
- **kwargs : Any
Any keyword arguments.
- Returns:¶
the same return type as the final step of the pipeline.
- Return type:¶
Any
- predict_counterfactuals(data: PredictiveDataset, *args: Any, **kwargs: Any) Any[source]¶
The pipeline version of the estimator
predict_counterfactualsmethod. Applicable if the final step of the pipeline has apredict_counterfactualsmethod implemented.- Parameters:¶
- data : dataset.PredictiveDataset¶
Input dataset.
- *args : Any
Any positional arguments.
- **kwargs : Any
Any keyword arguments.
- Returns:¶
the same return type as the final step of the pipeline.
- Return type:¶
Any
- tempor.methods.pipeline.prepend_base(base: type, bases: list[type]) list[type][source]¶
Prepend a base class to a list of base classes, if it is not already present.
- tempor.methods.pipeline.raise_not_implemented(*args: Any, **kwargs: Any) NoReturn[source]¶
Raise a
NotImplementedErrorif a method like_fit/predict/...is not implemented.- Parameters:¶
- *args : Any
Any positional arguments.
- **kwargs : Any
Any keyword arguments.
- Raises:¶
NotImplementedError – The requisite error.
- Returns:¶
Does not return, raises error.
- Return type:¶
NoReturn
-
class tempor.methods.pipeline.PipelineMeta(_PipelineMeta__name: str, _PipelineMeta__bases: tuple[type, ...], _PipelineMeta__namespace: dict[str, Any], plugins: tuple[type, ...] =
(), **kwds: Any)[source]¶ Bases:
ABCMetaThe metaclass
__new__method for defining the pipeline classes.- Parameters:¶
- cls : Any
The class.
- __name : str
The name of the class.
- __bases : Tuple[type, ...]
The list of base classes.
- __namespace : Dict[str, Any]
The namespace of the class.
- plugins : Tuple[Type, ...], optional¶
The list of pipeline plugins. Defaults to
tuple().- **kwds : Any
Any keyword arguments to be passed to
super().__new__.
- Returns:¶
The class.
- Return type:¶
Any
- tempor.methods.pipeline.pipeline_classes(names: list[str]) tuple[type, ...][source]¶
Return a list sequence of method plugin classes based on a sequence of fully-qualified
namesprovided.
- tempor.methods.pipeline.pipeline(plugins_str: list[str]) type[PipelineBase][source]¶
Use this method to create pipelines.
Generates a pipeline (
PipelineBase) class with an implementation of the necessary methods (fit,sample_hyperparametersetc.), based on a sequence of steps defined byplugins_str.All but the last steps must be data transformer plugins, and the last step must be a predictive method plugin.
This method will return a pipeline class (
Type[PipelineBase]), which should be instantiated. At time of instantiation,__init__input parameters for each step’s method plugin can be provided. SeePipelineBasefor details.