paddlets.transform.base
- class BaseTransform[source]
Bases:
objectBase class for all data transformation classes (named transformers in this module)
Any subclass or transformer needs to inherit from this base class and implement
fit(),transform()andfit_transform()methods.- abstract fit(dataset: TSDataset)[source]
Learn the parameters from the dataset needed by the transformer.
Any non-abstract class inherited from this class should implement this method.
The parameters fitted by this method is transformer-specific. For example, the MinMaxScaler needs to compute the MIN and MAX, and the StandardScaler needs to compute the MEAN and STD (standard deviation) from the dataset.
- Parameters
dataset (TSDataset) – dataset from which to fit the transformer.
- abstract transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Apply the fitted transformer on the dataset
Any non-abstract class inherited from this class should implement this method.
- abstract fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Combine the above fit and transform into one method, firstly fitting the transformer from the dataset and then applying the fitted transformer on the dataset.
Any non-abstract class inherited from this class should implement this method.
- inverse_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Inversely transform the dataset output by the transform method.
Differ from other abstract methods, this method is not decorated by abc.abstractmethod. The reason is that not all the transformations can be transformed back inversely, thus, it is neither possible nor mandatory for all sub classes inherited from this base class to implement this method.
In general, other modules such as Pipeline will possibly call this method WITHOUT knowing if the called transform instance has implemented this method. To work around this, instead of simply using pass expression as the default placeholder, this method raises a NotImplementedError to enable the callers (e.g. Pipeline) to use try-except mechanism to identify those data transformation operators that do NOT implement this method.