Skip to content

discrete_derivative

DiscreteDerivative(features, *, method='central', derivative_suffix='_derivative')

Bases: Transform

Calculates the discrete derivative of time series features.

Calculates the discrete derivative of time series features using either forward, backward, or central differences.

Initializes the DiscreteDerivative transform.

Parameters:

Name Type Description Default
features str | Iterable[str]

Features that shall be differentiated. Result features will be named <feature>_derivative.

required
method DiscreteDerivativeKind

Method to use for calculating the derivative. Valid options are "forward", "backward", and "central". Defaults to "central".

'central'
derivative_suffix str

Suffix to append to the feature name for the resulting derivative feature. Defaults to "_derivative".

'_derivative'
Source code in src/flowcean/polars/transforms/discrete_derivative.py
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
def __init__(
    self,
    features: str | Iterable[str],
    *,
    method: DiscreteDerivativeKind = "central",
    derivative_suffix: str = "_derivative",
) -> None:
    """Initializes the DiscreteDerivative transform.

    Args:
        features: Features that shall be differentiated. Result features
            will be named `<feature>_derivative`.
        method: Method to use for calculating the derivative. Valid options
            are "forward", "backward", and "central".
            Defaults to "central".
        derivative_suffix: Suffix to append to the feature name for the
            resulting derivative feature. Defaults to "_derivative".
    """
    self.features = [features] if isinstance(features, str) else features
    self.method = method
    self.derivative_suffix = derivative_suffix