Skip to content

dynamicslab/pysindy

Repository files navigation

PySINDy

BuildCI Documentation Status PyPI Codecov JOSS1 JOSS2 DOI

PySINDy is a package for system identification, primarily revolving around the method of Sparse Identification of Nonlinear Dynamical systems (SINDy) method introduced in Brunton et al. (2016a). It also includes other methods from related literature.

System identification refers to the process of using measurement data to infer the governing dynamics. Once discovered, these equations can make predictions about future states, can inform control inputs, or can enable the theoretical study using analytical techniques. The resulting models are inherently interpretable and generalizable.

First Steps

Installation

The preferred way to install is with pip or conda e.g. pip install pysindy. You may have to add the --user option. Pysindy also provides several extras, e.g. pip install pysindy[miosr]:

cvxpy
Convex optimizer SR3 and subclasses
miosr
Branch-and-bound optimizer for L0-constraint, MIOSR
sbr
Bayesian regression optimizer yielding posteriors, SBR.

Example

Suppose we have measurements of the position of a particle obeying the following dynamical system at different points in time

x' &= -2 x \\
y' &= y

Note that this system of differential equations decouples into two differential equations whose solutions are simply

x(t) &= x_0 * exp(-2 * t) \\
y(t) &= y_0 * exp(t)

This example uses the initial conditions x_0 = 3 and y_0 = 0.5. It then fits and prints the discovered model

import numpy as np
import pysindy as ps

t = np.linspace(0, 1, 100)
x = 3 * np.exp(-2 * t)
y = 0.5 * np.exp(t)
X = np.stack((x, y), axis=-1)  # First column is x, second is y

model = ps.SINDy()
model.fit(X, t=t, feature_names=["x", "y"])
model.print()

which correctly results in

x' = -2.000 x
y' = 1.000 y

PySINDy provides numerous other features not shown here. We have a variety of tutorials and examples, starting with generating data and fitting models.

Getting Help

  • If you have a question or find a bug, please open an issue on github.
  • The documentation site for PySINDy can be found here. A video overview of PySINDy can be found on Youtube. We have also created a video playlist with practical PySINDy tips.
  • To understand more about the types of objects in pysindy, see the object model.
  • If you want to fix a problem, add a feature, or share an example, check the **Contributor** Guide.
  • If you are using pysindy in academic work, please see Academic Use for recommendations, including citations.

Related packages

  • Deeptime - A Python library for the analysis of time series data with methods for dimension reduction, clustering, and Markov model estimation.
  • PyDMD - A Python package using the Dynamic Mode Decomposition (DMD) for a data-driven model simplification based on spatiotemporal coherent structures. DMD is a great alternative to SINDy.
  • PySINDyGUI - A slick-looking GUI for PySINDy.
  • SEED - Software for the Extraction of Equations from Data: a GUI for many of the methods provided by PySINDy.
  • SymINDy - A Python package combining SINDy with genetic programming-based symbolic regression, used for the functions library optimization.
  • derivative - A Python package for differentiating (and optionally, smoothing) data, used by pysindy