PySINDy: A comprehensive Python package for robust sparse system identification

Alan A. Kaptanoglu, Brian M. de Silva, Urban Fasel, Kadierdan Kaheman, Andy J. Goldschmidt, Jared Callaham, Charles B. Delahunt, Zachary G. Nicolaou, Kathleen Champion, Jean-Christophe Loiseau, J. Nathan Kutz, Steven L. Brunton

Abstract

Automated data-driven modeling, the process of directly discovering the governing equations of a system from data, is increasingly being used across the scientific community. PySINDy is a Python package that provides tools for applying the sparse identification of nonlinear dynamics (SINDy) approach to data-driven model discovery. In this major update to PySINDy, we implement several advanced features that enable the discovery of more general differential equations from noisy and limited data. The library of candidate terms is extended for the identification of actuated systems, partial differential equations (PDEs), and implicit differential equations. Robust formulations, including the integral form of SINDy and ensembling techniques, are also implemented to improve performance for real-world data. Finally, we provide a range of new optimization algorithms, including several sparse regression techniques and algorithms to enforce and promote inequality constraints and stability. Together, these updates enable entirely new SINDy model discovery capabilities that have not been reported in the literature, such as constrained PDE identification and ensembling with different sparse regression optimizers.

Introduction

In modern science and engineering, researchers often possess massive datasets collected from sensors but lack the underlying mathematical laws that describe the system's behavior. Traditionally, these governing equations are derived from first principles—a process that is increasingly difficult for complex, multi-scale systems.

The Sparse Identification of Nonlinear Dynamics (SINDy) algorithm was developed to automate this discovery process. SINDy operates on the principle of parsimony, assuming that the dynamics of a system are governed by only a few dominant terms from a large library of potential candidate functions. While powerful, early iterations of SINDy faced challenges with high noise levels, limited data availability, and the identification of partial differential equations (PDEs). This paper details a major update to the PySINDy package, introducing a comprehensive suite of tools designed to overcome these practical hurdles.

Methodology

PySINDy models the dynamics of a system using the sparse regression framework: $\dot{q} \approx \Theta(q)\Xi$, where $\Theta$ represents a library of candidate functions (such as polynomials or trigonometric terms) and $\Xi$ is a matrix of sparse coefficients to be identified. The latest update introduces several core enhancements to this workflow:

  • Advanced Differentiation: To mitigate the effects of noise, the package now supports Savitzky-Golay, spectral, spline, and total variational derivatives.
  • Robust Formulations: The implementation of the integral form of SINDy allows the algorithm to avoid noisy numerical differentiation by integrating the equations. Additionally, ensembling techniques (similar to bagging) have been added to enhance model reliability and consensus.
  • New Optimizers: The library includes specialized algorithms like SR3 (Sparse Relaxed Regularized Regression) and "Trapping SINDy," which enforces global stability to ensure the discovered models remain physically plausible.
  • Generalized Libraries: Users can now easily combine, tensor, or concatenate different candidate libraries, facilitating the modeling of actuated systems with control inputs and complex PDEs.
Schematic representation of the PySINDy package architecture, highlighting differentiation methods, feature libraries, and optimization algorithms.

Experimental Validation and Results

The versatility of the updated package is demonstrated through several benchmarks, ranging from standard nonlinear oscillators to complex fluid dynamics. A primary highlight is the successful identification of the Kuramoto-Sivashinsky (KS) PDE, a chaotic spatiotemporal system.

Using data from 1024 spatial points over 251 time steps, PySINDy identified the governing equation as: $$q_t = -0.98qq_x - 0.99q_{xx} - 1.0q_{xxxx}$$ This result is remarkably close to the ground truth coefficients of $-1, -1, -1$. The package maintains a user-friendly API that adheres to scikit-learn standards, ensuring accessibility for researchers familiar with standard Python machine learning workflows.

Visualization of the identified spatiotemporal dynamics for the Kuramoto-Sivashinsky partial differential equation.

Discussion and Future Work

The core insight of PySINDy is that sparsity serves as a proxy for physical truth; by choosing the simplest model that fits the data, the algorithm often recovers the actual physical laws. Unlike "black-box" neural networks, PySINDy allows for the integration of known physics—such as conservation of energy or symmetry—as inequality constraints during optimization. Ensembling further reduces the likelihood of discovering spurious terms caused by noise.

Despite its power, PySINDy remains dependent on the user-provided library of candidate terms. Future work aims to integrate automatic differentiation, Bayesian SINDy for uncertainty quantification, and stochastic SINDy for systems governed by random processes. These advancements will continue to push the boundaries of automated scientific discovery.

Summary updated

BibTeX
@article{kaptanoglu2022pysindy,
  author = {Alan A. Kaptanoglu and Brian M. de Silva and Urban Fasel and Kadierdan Kaheman and Andy J. Goldschmidt and Jared Callaham and Charles B. Delahunt and Zachary G. Nicolaou and Kathleen Champion and Jean-Christophe Loiseau and J. Nathan Kutz and Steven L. Brunton},
  title = {{PySINDy: A comprehensive Python package for robust sparse system identification}},
  journal = {The Journal of Open Source Software},
  year = {2022},
  doi = {10.21105/joss.03994},
}
Figure