paddlets.transform.normalization
- class MinMaxScaler(cols: Optional[Union[List[str], str]] = None, f_range: tuple = (0, 1), clip: bool = False)[source]
Bases:
BaseTransformTransform a dataset by scaling the values of sepcified column(s) to the expected range: [min, max].
The transformation is done by:
X_std = (X - X.min) / (X.max - X.min)
X_scaled = X_std * (max - min) + min
- Parameters
cols (str|List) – Column name(s) to be scaled.
f_range (tuple) – tuple (min, max), default=(0, 1), Desired range of transformed values.
clip (bool) – Set to True to clip transformed values of held-out data to provided feature range.
- Returns
None
- fit(dataset: TSDataset)[source]
Compute the MIN and MAX parameters needed by the scaler.
- Parameters
dataset (TSDataset) – dataset from which to compute the parameters.
- Returns
self
- transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Transform the dataset based on the computed parameters.
- inverse_transform(dataset: TSDataset, cols: Optional[Union[List[str], str]] = None, inplace: bool = False) TSDataset[source]
Inversely transform the scaled dataset.
- class StandardScaler(cols: Optional[Union[List[str], str]] = None, with_mean: bool = True, with_std: bool = True)[source]
Bases:
BaseTransformTransform a dataset by scaling the values of sepcified column(s) to zero mean and unit variance.
The transformation is done by: z = (x - u) / s.
where u is the MEAN or zero if with_mean=False, and s is the standard deviation or one if with_std=False.
- Parameters
cols (str|List) – Column name or names to be scaled.
with_mean (bool) – If True, center the data before scaling.
with_std (bool) – If True, scale the data to unit variance.
- Returns
None
- fit(dataset: TSDataset)[source]
Compute the mean and std parameters needed by the scaler.
- Parameters
dataset (TSDataset) – dataset from which to compute parameters.
- Returns
self
- transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Transform the dataset based on the computed parameters.
- inverse_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]
Inversely transform the scaled dataset.