Differencer
Apply iterative differences to a timeseries.
Quickstart
from sktime.transformations.difference import Differencer
estimator = Differencer(lags=1, na_handling='fill_zero', memory='all')Parameters(3)
- lagsint or array-like, default = 1
The lags used to difference the data. If a single
intvalue is- na_handlingstr, optional, default = “fill_zero”
How to handle the NaNs that appear at the start of the series from differencing Example: there are only 3 differences in a series of length 4,
differencing [a, b, c, d] gives [?, b-a, c-b, d-c] so we need to determine what happens with the “?” (= unknown value)
“drop_na” - unknown value(s) are dropped, the series is shortened “keep_na” - unknown value(s) is/are replaced by NaN “fill_zero” - unknown value(s) is/are replaced by zero
- memorystr, optional, default = “all”
how much of previously seen X to remember, for exact reconstruction of inverse “all”: estimator remembers all X, inverse is correct for all indices seen “latest”: estimator only remembers latest X necessary for future reconstruction
inverses at any time stamps after fit are correct, but not past time stamps
“none”: estimator does not remember any X, inverse is direct cumsum
Examples
>>> from sktime.transformations.difference import Differencer
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> transformer = Differencer (lags = [1, 12 ])
>>> y_transform = transformer. fit_transform (y)