TimeSeriesTransform#

class openstef_core.transforms.TimeSeriesTransform[source]#

Bases: Transform[TimeSeriesDataset, TimeSeriesDataset]

Abstract base class for transforming regular time series datasets.

This class defines the interface for data transformations that operate on TimeSeriesDataset instances. Transforms follow the scikit-learn pattern with separate fit and transform phases, allowing for stateful transformations that learn parameters from training data.

Subclasses must implement the transform method and optionally override the fit method if the transformation requires learning parameters from data.

Example

Implement a simple scaling transform

>>> class ScaleTransform(TimeSeriesTransform):
...     def __init__(self):
...         self.scale_factor = None
...
...     @property
...     def is_fitted(self) -> bool:
...         return self.scale_factor is not None
...
...     def fit(self, data):
...         self.scale_factor = data.data.max().max()
...
...     def transform(self, data):
...         scaled_data = data.data / self.scale_factor
...         return TimeSeriesDataset(scaled_data, data.sample_interval)
property is_fitted: bool#

Check if the transform has been fitted.

fit(data: TimeSeriesDataset) None[source]#

Fit the transform to the input data.

This method should be called before applying the transform to the data. It allows the transform to learn any necessary parameters from the data.

Parameters:
Return type:

None

abstractmethod features_added() list[str][source]#

List of feature names added by this transform.

Return type:

list[str]

Returns:

A list of strings representing the names of features added to the dataset by this transform. Default is an empty list.