pysindy icon indicating copy to clipboard operation
pysindy copied to clipboard

Save DifferentiationMethod smoothed values

Open Jacob-Stevens-Haas opened this issue 3 years ago • 0 comments

This change now allows differentiation methods that implicitly smooth x to store that smoothed value in the paramter smoothed_x_ so that SINDy can use it in the feature library. Currently, this is only SmoothedFiniteDifference, but upon acceptance of https://github.com/andgoldschmidt/derivative/pull/15, SINDyDerivative where kind="kalman" will also implement it. The hope is that using smoothed coordinate values will help in higher-noise cases.

I've made this a draft PR, however, because the last step is bumping the derivative package requirement to whatever is released after that PR is done. This PR will fail tests until then. That said, the code itself is ready for review.

API changes:

  • BaseDifferentiation and subclasses gain a smoothed_x_ attribute.
  • SmoothedFiniteDifference and SINDyDerivative gain a kwarg save_smooth=True, which can be set to False to disable the new behavior (and store the unsmoothed Xs in smoothed_x_.
  • BaseFeatureLibrary.calc_trajectory() (and its subclasses) now return a tuple of x, x_dot (the integral for WeakPDELibrary) instead of just the second tuple element. ("breaking" change, and the main reason that I tagged the last release of master as pre-release)

Other chages:

  • Example 5 (Differentiation Methods) adds Kalman smoothing and shows the effects of using the smoothed x in the feature libraries (it works better, no surprise there)
  • Example 5 offloads some plotting code into it's own utils.py module, making the overall notebook easier to read.
  • Tests added for API changes.

Sorry for so many PRs :bowtie:... This should be the last major change I submit before my general exam at the end of September. Only bugfixes and updating notebooks to the new format between now and then.

Jacob-Stevens-Haas avatar Aug 13 '22 18:08 Jacob-Stevens-Haas