paddlets.transform.ksigma

class KSigma(cols: Union[str, List[str]], k: float = 3.0)[source]

Bases: BaseTransform

The ksigma method for outlier detection and replacement. It involves:

  1. Calculate the mean (mu) and standard deviation (std) of a column.

  2. Determine the interval of normal data according to mu and std: [mu - k * std, mu + k * std] where k is a hyper-parameter (3.0 by default). Any value of the interval will be considered as an outlier.

  3. Replace the outliers with mu.

Parameters
  • cols (str|List[str]) – Column name or Column names (Each column will be handled individually when multiple columns are provided).

  • k (float) – The hyper-parameter which takes a positive value (3.0 by default).

Returns

None

fit_one(dataset: TSDataset)[source]

The process to determine the mean (mu), standard deviation (std), and valid interval ([mu - k * std, mu + k * std])

Parameters

dataset (TSDataset) – TSDataset

Returns

self

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

Replace the outliers with mu

Parameters
  • dataset (TSDataset) – TSDataset

  • inplace (bool) – Whether to perform transform inplace, the default is False.

Returns

TSDataset