paddlets.transform.normalization

class MinMaxScaler(cols: Optional[Union[List[str], str]] = None, f_range: tuple = (0, 1), clip: bool = False)[source]

Bases: BaseTransform

Transform 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.

Parameters
  • dataset (TSDataset) – Dataset to be transformed.

  • inplace (bool) – Set to True to perform inplace row normalization and avoid a copy.

Returns

Transformed TSDataset.

Return type

new_ts(TSDataset)

inverse_transform(dataset: TSDataset, cols: Optional[Union[List[str], str]] = None, inplace: bool = False) TSDataset[source]

Inversely transform the scaled dataset.

Parameters
  • dataset (TSDataset) – dataset to be inversely transformed.

  • inplace (bool) – Set to True to perform inplace operation and avoid data copy.

Returns

Inversely transformed TSDataset.

Return type

TSDataset

fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]

First fit the scaler, and then do transformation.

Parameters
  • tsdata (TSDataset) – dataset to be processed.

  • inplace (bool) – Set to True to perform inplace operation and avoid data copy.

Returns

Transformed TSDataset.

Return type

TSDataset

class StandardScaler(cols: Optional[Union[List[str], str]] = None, with_mean: bool = True, with_std: bool = True)[source]

Bases: BaseTransform

Transform 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.

Parameters
  • dataset (TSDataset) – dataset to be transformed.

  • inplace (bool) – Set to True to perform inplace operation and avoid data copy.

Returns

Transformed TSDataset.

Return type

new_ts(TSDataset)

inverse_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]

Inversely transform the scaled dataset.

Parameters
  • dataset (TSDataset) – dataset to be inversely transformed.

  • inplace (bool) – Set to True to perform inplace operation and avoid data copy.

Returns

Inversely transformed TSDataset.

Return type

TSDataset

fit_transform(dataset: TSDataset, inplace: bool = False) TSDataset[source]

First fit the scaler, and then do transformation.

Parameters
  • tsdata (TSDataset) – dataset to be processed.

  • inplace (bool) – Set to True to perform inplace operation and avoid data copy.

Returns

Transformed TSDataset.

Return type

TSDataset