Back to models
Transformer

SavitzkyGolayTransformer

Savitzky-Golay filter for smoothing or differentiating time series.

Uses local polynomial regression (convolution) to smooth data or to compute numerical derivatives, preserving features of the distribution like relative maxima and minima better than moving average approaches.

Wraps scipy.signal.savgol_filter.

Quickstart

python
from sktime.transformations.savitzky_golay import SavitzkyGolayTransformer

estimator = SavitzkyGolayTransformer(window_length=5, polyorder=2, deriv=0, delta=1.0, mode='interp', cval=0.0)

Tags

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
Yes
Requires Xrequires_X
Yes
Requires yrequires_y
No
X and y need the same indexX-y-must-have-same-index
No

Parameters(6)

window_lengthint, default=5
Length of the filter window. Must be a positive odd integer.
polyorderint, default=2

Order of the polynomial used to fit the samples. Must be less than window_length.

derivint, default=0
Order of the derivative to compute. Use 0 to simply smooth the data without differentiation.
deltafloat, default=1.0

Spacing of the samples to which the filter will be applied. Only relevant when deriv > 0.

modestr, default=”interp”

How to extend the signal at the boundaries. One of "interp", "mirror", "nearest", "wrap", "constant".

cvalfloat, default=0.0

Value to fill past the edges of the input when mode is "constant".

Examples

>>> from sktime.transformations.savitzky_golay import (
... SavitzkyGolayTransformer,
... )
>>> from sktime.datasets import load_airline
>>> y = load_airline ()
>>> t = SavitzkyGolayTransformer (window_length = 7, polyorder = 2)
>>> y_smooth = t. fit_transform (y)