Transformer
DerivativeSlopeTransformer
Derivative slope transformer.
Transformer that computes the derivative of a time series, using numpy.gradient.
Mathematically, uses the central difference method in the interior and first differences at the boundaries, with respect to integer (iloc) index, that is:
\[\begin{align}\begin{aligned}f'(x) = (f(x+1) - f(x-1)) / 2, \mbox{ for } 1 \leq x \leq n-2\\f'(0) = f(1) - f(0)\\f'(n-1) = f(n-1) - f(n-2)\end{aligned}\end{align} \]
where n is the length of the time series, and indices range from 0 to n-1.
Schnellstart
python
from sktime.transformations.summarize import DerivativeSlopeTransformer
estimator = DerivativeSlopeTransformerBeispiele
>>> import pandas as pd
>>> from sktime.transformations.summarize import DerivativeSlopeTransformer
>>> X = pd. DataFrame ({ "a": [10, 12, 15, 20, 22 ]})
>>> t = DerivativeSlopeTransformer ()
>>> t. fit_transform (X) a 0 2.0 1 2.5 2 4.0 3 3.5 4 2.0 Works on multivariate data as well, computing the derivative independently for each column:
>>> X2 = pd. DataFrame ({ "a": [10, 12, 15, 20, 22 ], "b": [5, 5, 6, 8, 8 ]})
>>> t. fit_transform (X2) a b 0 2.0 0.0 1 2.5 0.5 2 4.0 1.5 3 3.5 1.0 4 2.0 0.0