Kooplearn

kooplearn is a Python library to learn evolution operators — also known as Koopman [1] or Transfer [2] operators — from data. kooplearn models can

  1. Predict the evolution of states and observables.

  2. Estimate the eigenvalues and eigenfucntions of the learned evolution operators.

  3. Compute the dynamic mode decomposition of states and observables.

  4. Learn neural-network representations \(x_t \mapsto \varphi(x_t)\) for evolution operators.

Why Choosing kooplearn?

It is easy to use, and strictly adheres to the scikit-learn API. Its Kernel estimators are state-of-the-art, and blazingly fast ⚡️:

_images/fit_time_benchmarks_light.svg

Fit time of a Kernel model (Gaussian kernel) on a dataset of 5000 observations from the Lorenz 63 dynamical system. Runned on a system equipped with an Intel Core i9-9900X CPU (3.50GHz) and 48GB of RAM memory.

_images/fit_time_benchmarks_dark.svg

Fit time of a Kernel model (Gaussian kernel) on a dataset of 5000 observations from the Lorenz 63 dynamical system. Runned on a system equipped with an Intel Core i9-9900X CPU (3.50GHz) and 48GB of RAM memory.

Kooplearn also includes representation learning losses (implemented both in PyTorch and JAX) to train neural-network Koopman embeddings, and offers a collection of datasets for benchmarking evolution operator learning algorithms.

Installation

To install the core version of kooplearn, run

pip install kooplearn
uv add kooplearn

To be able to learn neural-network representations using the representation-learning losses in kooplearn.torch or kooplearn.jax, run

# Torch
pip install "kooplearn[torch]"
# JAX
pip install "kooplearn[jax]"
# Torch
uv add "kooplearn[torch]"
# JAX
uv add "kooplearn[jax]"

Quickstart

import numpy as np
from kooplearn.datasets import make_duffing
from kooplearn.kernel import KernelRidge

# Sample data from the Duffing oscillator
data = make_duffing(X0 = np.array([0, 0]), n_steps=1000)

# Fit the model
model = KernelRidge(n_components=4, kernel='rbf', alpha=1e-5)
model.fit(data)

Learn more

Theory Primer
primer.html
Examples
examples.html
API reference
api/index.html

[1]

Bernard O Koopman. Hamiltonian systems and transformation in hilbert space. Proceedings of the National Academy of Sciences, 17(5):315–318, 1931.

[2]

David Applebaum. Lévy Processes and Stochastic Calculus. Cambridge University Press, April 2009. ISBN 9780511809781. URL: http://dx.doi.org/10.1017/CBO9780511809781, doi:10.1017/cbo9780511809781.