dynamicslab/pysindy
A package for the sparse identification of nonlinear dynamical systems from data
PySINDy – Sparse Identification of Nonlinear Dynamical Systems
What it is:
A Python library that discovers governing equations of dynamical systems directly from measurement data. It implements the SINDy (Sparse Identification of Nonlinear Dynamics) algorithm and several related sparse‑regression methods.
Why it matters:
The models it produces are interpretable (explicit equations) and often compact, making them useful for prediction, control design, or scientific insight without needing a black‑box neural network.
Key capabilities
- Fit continuous‑time dynamical systems from time‑series snapshots.
- Choose among multiple sparse optimizers (e.g., LASSO, SR3, MIOSR, Bayesian SBR).
- Automatic construction of a library of candidate functions (polynomials, trigonometric terms, etc.).
- Built‑in support for custom feature libraries and custom optimizers via optional extras.
- Export the discovered equations in symbolic form, NumPy functions, or LaTeX.
Typical workflow
- Collect data – a matrix
Xof state measurements and a time vectort. - Create a model –
model = pysindy.SINDy()(optionally specify optimizer, feature library, etc.). - Fit –
model.fit(X, t=t). - Inspect –
model.print()ormodel.coefficients()to see the identified equations. - Use – simulate forward, design controllers, or analyse the symbolic model.
Installation
pip install pysindy # core package
# optional optimizers
pip install pysindy[miosr] # branch‑and‑bound L0 optimizer
pip install pysindy[cvxpy] # convex SR3 optimizer
pip install pysindy[sbr] # Bayesian regression optimizer
Conda users can also install via conda install -c conda-forge pysindy.
Minimal example (identifying a simple linear system)
import numpy as np
import pysindy as ps
# synthetic data for x' = -2x, y' = y
t = np.linspace(0, 1, 100)
x = 3 * np.exp(-2 * t)
y = 0.5 * np.exp(t)
X = np.column_stack([x, y])
model = ps.SINDy()
model.fit(X, t=t, feature_names=["x", "y"])
model.print()
Output:
x' = -2.000 x
y' = 1.000 y
Documentation & help
- Full docs: https://pysindy.readthedocs.io
- Video overview & tutorial playlist on YouTube (links in README).
- Issue tracker for bugs/questions: https://github.com/dynamicslab/pysindy/issues
- Contribution guide for adding features or fixing bugs.
Related tools
- Deeptime – time‑series analysis, Markov models.
- PyDMD – Dynamic Mode Decomposition, an alternative data‑driven modeling approach.
- PySINDyGUI / SEED – graphical front‑ends for the same algorithms.
Who should use it Researchers and engineers who need compact, analytically tractable models of physical, biological, or engineered systems from experimental data, especially when interpretability is a priority over raw predictive power.
Related
- Project
- Project
- Project
- Project