feat(stats): add Savitzky-Golay smoothing filter - #1986
Open
Shizoqua wants to merge 1 commit into
Open
Conversation
Adds stats.SavitzkyGolay, a rolling Savitzky-Golay filter that fits a polynomial of a given degree to a sliding window of observations by least squares and returns the smoothed value of the most recent point. Because the fit is evaluated at the last point of the window, the filter is causal and can be used online, e.g. to smooth sensor or market signals before feature extraction. The coefficients are computed once via scipy.signal.savgol_coeffs and applied with a fixed-size deque; get() returns None until the window is full. Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com> Signed-off-by: Shizoqua <136805224+Shizoqua@users.noreply.github.com>
Shizoqua
requested review from
AdilZouitine,
MaxHalford and
smastelini
as code owners
August 12, 2026 12:46
Merging this PR will not alter performance
Performance Changes
Comparing Footnotes
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
stats.SavitzkyGolay, a rolling Savitzky-Golay smoothing filter as requested in #1424.Savitzky-Golay fits a polynomial of a given degree to a sliding window of observations by least squares and returns the smoothed value of the most recent point via the precomputed
scipy.signal.savgol_coeffsdot product. Because the polynomial is evaluated at the last point of the window, the filter is causal and compatible with online learning.__init__, applied over a fixed-sizedequeget()returnsNoneuntil the window has enough observationswindow_size/polyorderfollow scipy's constraint (polyorder < window_size, enforced by scipy)stats/__init__.pyand the docs navVerification:
pytest tests/stats— 175 passed (incl. doctests)ruff check/ruff format --checkcleanDCO sign-off included.