Skip to content

fumito100111/ddsm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DDSM (Data-driven Dynamical Systems Modeling)

Version Python Version License: MIT GitHub issues GitHub stars

Overview

DDSM is a Python library for Data-driven Dynamical systems modeling. This library provides tools for modeling and analyzing dynamical systems using data-driven approaches.

Note

Estimators in DDSM are fully compatible with the Scikit-learn API.

Table of Contents

Requirements

DDSM requires Python 3.12 or later.

Installation

You can install the latest version of DDSM using pip (From GitHub):

python -m pip install git+https://github.com/fumito100111/ddsm.git@v0.1.2

Tip

If you want to install a specific version, specify it after the @ symbol. For example, to install version v0.1.2, use @v0.1.2.

Usage

Supported Estimators

Note

For more details on how to use each estimator, please refer to the samples directory.

EDMD

import numpy as np
from ddsm.dicts import MonomialsDict
from ddsm.estimators import EDMD

dt = 1.0e-3                 # Time interval between data points
x = np.random.rand(100, 2)  # Sample data at time t
y = np.sin(x)               # Sample target data at time t + dt

estimator = EDMD(
    psix_cls=MonomialsDict,
    psix_kwargs={"degree": 2},
    psiy_cls=MonomialsDict,
    psiy_kwargs={"degree": 2},
    reg='none'
)
estimator.fit(x, y)

K = estimator.right_K
L = estimator.left_L(dt=dt)

gEDMD

import numpy as np
from ddsm.dicts import MonomialsDict
from ddsm.estimators import gEDMD

dt = 1.0e-3                 # Time interval between data points
x = np.random.rand(100, 2)  # Sample data at time t
y = np.sin(x)               # Sample target data at time t + dt
dx = (y - x) / dt           # Sample derivative data at time t

estimator = gEDMD(
    psi_cls=MonomialsDict,
    psi_kwargs={"degree": 2},
    reg='lasso',
    reg_kwargs={"alpha": 0.1}
)
estimator.fit(x, dx)

L = estimator.right_L
K = estimator.left_K(dt=dt)

SINDy

import numpy as np
from ddsm.dicts import MonomialsDict
from ddsm.estimators import SINDy

dt = 1.0e-3                 # Time interval between data points
x = np.random.rand(100, 2)  # Sample data at time t
y = np.sin(x)               # Sample target data at time t + dt
dx = (y - x) / dt           # Sample derivative data at time t

estimator = SINDy(
    psi_cls=MonomialsDict,
    psi_kwargs={"degree": 2},
    threshold=0.1,
    max_iter=20
)
estimator.fit(x, dx)

L = estimator.right_L

Utilities

DDSM also provides the following utility functions:

Note

For more details on how to use the utility functions, please refer to the samples directory.

ddsm.utils.generator_to_eq

This function converts a generator matrix obtained into a system of equations, separating the drift and diffusion terms.

import numpy as np
from ddsm.dicts import MonomialsDict
from ddsm.estimators import gEDMD
from ddsm.utils import generator_to_eq

dt = 1.0e-3                 # Time interval between data points
x = np.random.rand(100, 2)  # Sample data at time t
y = np.sin(x)               # Sample target data at time t + dt
dx = (y - x) / dt           # Sample derivative data at time t

estimator = gEDMD(
    psi_cls=MonomialsDict,
    psi_kwargs={"degree": 2},
    reg='lasso',
    reg_kwargs={"alpha": 0.1}
)
estimator.fit(x, dx)

right_L = estimator.right_L
psi = estimator.psi_
eq = generator_to_eq(right_L, psi)
print('----- Drift Term -----')
print(eq.drift)
print('----- Diffusion Term -----')
print(eq.diff)

References

  1. Williams, M. O., Kevrekidis, I. G., & Rowley, C. W. (2015). A Data-Driven Approximation of the Koopman Operator: Extending Dynamic Mode Decomposition. Journal of Nonlinear Science, 25, 1307-1346.

  2. Brunton, S. L., Proctor, J. L., & Kutz, J. N. (2016). Discovering governing equations from data by sparse identification of nonlinear dynamical systems. Proceedings of the National Academy of Sciences (PNAS).

  3. Klus, S., Nüske, F., Peitz, S., Niemann, J. H., Clementi, C., & Schütte, C. (2020). Data-driven approximation of the Koopman generator: Model reduction, system identification, and control. Physica D: Nonlinear Phenomena, 406, 132416.

Open Source Software

DDSM uses the following open source software:

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A Python library for Data-driven Dynamical Systems Modeling with the Scikit-learn compatible API

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors