TimeSeriesImputerTransform

class TimeSeriesImputerTransform(in_column: str = 'target', strategy: str = ImputerMode.zero, window: int = - 1, seasonality: int = 1, default_value: Optional[float] = None)[source]

Bases: etna.transforms.base.PerSegmentWrapper

Transform to fill NaNs in series of a given dataframe.

  • It is assumed that given series begins with first non NaN value.

  • This transform can’t fill NaNs in the future, only on train data.

  • This transform can’t fill NaNs if all values are NaNs. In this case exception is raised.

Warning

This transform can suffer from look-ahead bias in ‘mean’ mode. For transforming data at some timestamp it uses information from the whole train part.

Create instance of TimeSeriesImputerTransform.

Parameters
  • in_column (str) – name of processed column

  • strategy (str) –

    filling value in missing timestamps:

    • If “zero”, then replace missing dates with zeros

    • If “mean”, then replace missing dates using the mean in fit stage.

    • If “running_mean” then replace missing dates using mean of subset of data

    • If “forward_fill” then replace missing dates using last existing value

    • If “seasonal” then replace missing dates using seasonal moving average

  • window (int) –

    In case of moving average and seasonality.

    • If window=-1 all previous dates are taken in account

    • Otherwise only window previous dates

  • seasonality (int) – the length of the seasonality

  • default_value (Optional[float]) – value which will be used to impute the NaNs left after applying the imputer with the chosen strategy

Raises

ValueError: – if incorrect strategy given

Inherited-members

Methods

fit(df)

Fit transform on each segment.

fit_transform(df)

May be reimplemented.

inverse_transform(df)

Apply inverse_transform to each segment.

transform(df)

Apply transform to each segment separately.