TSCFiniteDifference#

class datafold.dynfold.TSCFiniteDifference(*, spacing='dt', scheme='center', diff_order=1, accuracy=2)[source]#

Bases: BaseEstimator, TSCTransformerMixin

Compute time derivative with finite difference scheme.

Note

The class internally uses the Python package findiff, which currently is optional in datafold. The class raises an ImportError if findiff is not installed.

Parameters:
  • spacing (Union[str, float]) – The time difference between samples. If “dt” (str) then the time sampling frequency of a TSCDataFrame.delta_time() is used during fit.

  • scheme (Literal['backward', 'center', 'forward']) – The finite difference scheme to apply, “center”, “backward” or “forward”.

  • diff_order (int) – The derivative order.

  • accuracy (int) – The convergence order of the finite difference scheme.

Variables:

spacing – The resolved time difference between samples. Equals the parameter input if it was of type :class`float`.

Methods Summary

fit(X[, y])

Set and validate time spacing between samples.

get_feature_names_out([input_features])

partial_fit(X[, y])

rtype:

Union[TSCDataFrame, ndarray]

transform(X)

Compute the finite difference values.

Methods Documentation

fit(X, y=None, **fit_params)[source]#

Set and validate time spacing between samples.

Parameters:
Returns:

self

Return type:

TSCFiniteDifference

Raises:

TSCException – If time series data has not a constant time delta or the input X has not the same value as specified in spacing during initialization.

get_feature_names_out(input_features=None)[source]#
partial_fit(X, y=None, **fit_params)[source]#
Return type:

Union[TSCDataFrame, ndarray]

transform(X)[source]#

Compute the finite difference values.

Parameters:

X (TSCDataFrame, pandas.DataFrame, numpy.ndarray) – Data of shape (n_samples, n_features).

Returns:

Transformed data of same shape and type as X.

Return type:

TSCDataFrame, pandas.DataFrame, numpy.ndarray

Raises:

TSCException – If input X has a different time delta than data during fit.