Abstract
PyKoopman is a Python package for the data-driven approximation of the Koopman operator associated with a dynamical system. The Koopman operator is a principled linear embedding of nonlinear dynamics and facilitates the prediction, estimation, and control of strongly nonlinear dynamics using linear systems theory. In particular, PyKoopman provides tools for data-driven system identification for unforced and actuated systems that build on the equation-free dynamic mode decomposition (DMD) and its variants. In this work, we provide a brief description of the mathematical underpinnings of the Koopman operator, an overview and demonstration of the features implemented in PyKoopman (with code examples), practical advice for users, and a list of potential extensions to PyKoopman.
Introduction
Nonlinear dynamical systems are ubiquitous in science and engineering—from fluid flow to robotics—but they are notoriously difficult to analyze and control. Traditionally, engineers rely on local linearization (like Taylor series expansion), which only works near a specific equilibrium point.
Koopman operator theory offers a more principled alternative: it seeks a "lifting" transformation that embeds nonlinear dynamics into a higher-dimensional space where the evolution appears linear. However, implementing these algorithms (like Dynamic Mode Decomposition or Extended DMD) from scratch is a significant barrier to entry. PyKoopman addresses this by providing a standardized, modular, and user-friendly toolkit to automate state-of-the-art Koopman operator algorithms.
Methods and Architecture
PyKoopman is structured around the Koopman model class, implemented as a scikit-learn estimator. The workflow generally follows two major steps: lifting the state into a higher-dimensional space and performing regression to find the linear operator.
1. Observables (Lifting)
The state $\mathbf{x}$ is transformed into a higher-dimensional vector of observables $\mathbf{z} = \Phi(\mathbf{x})$. PyKoopman includes a library of lifting functions, including:
- Multivariate polynomials.
- Radial Basis Functions (RBFs).
- Time-delay coordinates (Hankel matrices).
- Random Fourier features.
- NNDMD: Custom neural networks (via PyTorch) to learn the optimal lifting functions.
2. Regression
The package performs regression to find the best-fit linear operator $\mathbf{A}$ such that $\mathbf{z}_{k+1} \approx \mathbf{A}\mathbf{z}_k$. It supports various solvers, including standard DMD, DMD with control (DMDc), Kernel DMD, and multi-step recurrent loss optimization for neural networks.
The package also includes a differentiation module to compute time derivatives from trajectory data and an analytics module for sparsifying models.
Key Insights and Benchmarks
The paper demonstrates the package using several classic benchmark dynamical systems, such as the Slow Manifold, Van der Pol oscillator, and Lorenz system.
A key insight is the Modular "Mix-and-Match" capability: by decoupling the choice of observables from the regression method, PyKoopman allows users to experiment with different combinations (e.g., using RBF observables with a Total Least Squares solver). Furthermore, for Neural Network DMD (NNDMD), training on "recurrent loss" (predicting multiple steps into the future) leads to much more stable and accurate models than standard one-step prediction.
Results and Future Work
The authors demonstrate "excellent agreement" between ground truth and EDMD predictions for the slow manifold problem, even when starting from initial conditions not seen during training. The implementation of second-order optimization algorithms (like L-BFGS) for NNDMD was found to significantly accelerate training compared to standard first-order optimizers like Adam.
Future work includes addressing systems with a continuous spectrum (e.g., chaotic systems) by integrating methods like resDMD. Additionally, the authors plan to extend the package to handle bilinear forms and integrate more tightly with control synthesis libraries for Koopman-based MPC or LQR.
Software is available at http://github.com/dynamicslab/pykoopman
Summary updated