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.
Quickstart
python
from sktime.transformations.summarize import DerivativeSlopeTransformer
estimator = DerivativeSlopeTransformerTags
Capabilities
- Multivariate
- Unequal-length series
- Inverse transform: Not supported
- Missing values: Not supported
- Removes missing values: Not supported
- Equalizes series length: Not supported
Properties
- Input typescitype:transform-input
- Series
- Output typescitype:transform-output
- Series
- Label typescitype:transform-labels
- None
- Fit is emptyfit_is_empty
- Yes
- Keeps the time indextransform-returns-same-time-index
- No
- Requires Xrequires_X
- Yes
- Requires yrequires_y
- No
- X and y need the same indexX-y-must-have-same-index
- No
Examples
>>> 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