DataDrivenDiffEq.jl

repository·master·Indexed 19 days ago

https://github.com/sciml/datadrivendiffeq.jl

A SciML package for structural estimation and identification of differential equations from data, enabling automatic equation discovery. The suite includes specialized components: DataDrivenSparse.jl for sparse regression (SINDy, STLSQ, ADMM), DataDrivenSR.jl for symbolic regression via SymbolicRegression.jl, DataDrivenDMD.jl for Dynamic Mode Decomposition and Koopman-based methods, and DataDrivenLux.jl for deep-learning-based structure search using differentiable directed-acyclic-graph (DAG) models.

Tokens
6.6K
Snippets
19
Records
39
Agent score
65%

What's inside DataDrivenDiffEq.jl

  1. Overview of DataDrivenDiffEq.jl

    master
    DataDrivenDiffEq.jl is a package within the SciML ecosystem designed for data-driven differential equation structural estimation and identification. It provides tools to automatically discover governing equations from data and use those discovered equations to simulate perturbed dynamics.
  2. What is DataDrivenSR.jl

    master
    DataDrivenSR.jl is a package for discovering closed-form governing equations from data using symbolic regression methods. It is built on top of SymbolicRegression.jl. While it can be used as a standalone package, it is a component of the larger DataDrivenDiffEq.jl monorepo, which provides a complete suite for data-driven modeling.
  3. Overview of DataDrivenLux.jl

    master

    DataDrivenLux.jl is a deep-learning-based structure search component designed for discovering governing equations. It is built on top of Lux.jl and utilizes differentiable directed-acyclic-graph (DAG) candidate models to perform structure search.

    While it can be used as a standalone package, it is part of the larger DataDrivenDiffEq.jl monorepo. For a complete data-driven modeling suite, users should use DataDrivenDiffEq.jl.

  4. Overview of DataDrivenSparse.jl

    master

    DataDrivenSparse.jl is a specialized component within the DataDrivenDiffEq.jl ecosystem focused on sparse regression methods. It is designed to discover parsimonious governing equations from data using techniques such as SINDy, STLSQ, and ADMM.

    While it can be used as a standalone package, it is intended to be part of the broader DataDrivenDiffEq.jl suite for users requiring a complete data-driven modeling workflow.

  5. Overview of DataDrivenDMD.jl

    master

    DataDrivenDMD.jl is a specialized component within the DataDrivenDiffEq.jl monorepo. It focuses on Dynamic Mode Decomposition (DMD) and Koopman-based methods. These methods are used to discover linear operator approximations of dynamical systems directly from data.

    While DataDrivenDMD.jl can be used as a standalone package, it is recommended to use the full DataDrivenDiffEq.jl suite if you require a comprehensive collection of data-driven modeling tools.

  6. Use DataDrivenSR to infer systems of equations

    master

    DataDrivenSR provides an API wrapper around SymbolicRegression.jl designed to infer arbitrary systems of equations of the form:

    $$y_{i} = f(x_{i}, p, t_i, u_{i})$$

    where $y_i$ is the state, $x_i$ are inputs/features, $p$ are parameters, $t_i$ is time, and $u_i$ are control inputs. It is used for discovering the underlying mathematical structure of dynamical systems from data.

  7. Infer systems of equations using DataDrivenSparse

    master

    DataDrivenSparse is a framework for inferring systems of equations by expressing an unknown function $f$ as a linear combination of basis elements $\varphi_i$. It solves the sparse regression problem to find a sparse coefficient matrix $\Xi$ that minimizes the error between the observed data $Y$ and the basis evaluations $\varPhi$.

    For explicit systems of the form $y_{i} = f(x_{i}, p, t_i, u_{i})$, the goal is to solve: $$\Xi' = \min_{\Xi} \lVert\Xi \rVert_0 \text{ s.t. } \Xi \varPhi = Y$$

    For implicit systems of the form $f(y_i, x_i, p, t_i, u_i) = 0$, you can use an ImplicitOptimizer to solve: $$\Xi' = \min_{\Xi} \lVert\Xi \rVert_0 \text{ s.t. } \Xi \varPhi_y = 0$$ where $\varPhi_y$ contains basis functions that may depend on the target variables $y$.

    !!! warning "Tuning parameters for sparse regression" The algorithms are highly sensitive to hyperparameter tuning. Settings are problem-specific and depend on your data and the underlying equations. For automated hyperparameter optimization, consider using Hyperopt.jl.

  8. Understand Koopman operator-based inference in DataDrivenDMD

    master

    DataDrivenDMD uses operator-based inference to approximate dynamical systems. It assumes that a discrete dynamical system $x_{i+1} = f(x_{i}, p, t, u_{i})$ can be represented in a higher-dimensional observable space $\varphi$ where the evolution is linear: $\varphi_{i+1} = \mathcal K \circ \varphi_i$.

    Because the true Koopman operator $\mathcal K$ may exist in infinite dimensions, DataDrivenDMD uses Dynamic Mode Decomposition (DMD) to find a finite-dimensional matrix approximation $K$ such that $\hat \varphi_{i+1} \approx K \hat \varphi_i$. For continuous-time systems, it approximates the Koopman generator $K_G$ such that $\partial_t \hat \varphi \approx K_G \hat \varphi$.

  9. Configure common options for DataDrivenDiffEq solvers

    master

    Many algorithms in DataDrivenDiffEq share a set of configuration parameters collected in the DataDrivenCommonOptions struct. These can be passed to the solve function via the options keyword argument.

    The eval_expression option

    This keyword controls how functions are created during the inference process:

    • eval_expression=true: Uses standard eval. This follows normal Julia world-age rules, meaning the generated functions cannot be called from the function that created them.
    • eval_expression=false (Default): Uses GeneralizedGenerated.jl to allow for same-world-age evaluation. Warning: This can cause Julia to segfault if the basis functions are sufficiently large.

    Model Selection via the selector option

    To handle hyperparameters (like sparsity penalties or train-test splits), you can pass a selector to DataDrivenCommonOptions. The solver will return the model that minimizes this selector.

    Common built-in selectors include:

    • rss (Residual Sum of Squares)
    • bic (Bayesian Information Criterion)
    • aic (Akaike Information Criterion)
    • aicc (Corrected Akaike Information Criterion)
    • r2 (R-squared)

    Since subresults extend the StatsBase API, you can also provide a custom function as a selector.

    # Example: Using a custom selector for Mean Squared Error
    options = DataDrivenCommonOptions(selector = (x) -> rss(x) / nobs(x))
    res = solve(problem, basis, STLSQ(); options = options)
  10. Process and normalize data for differential equation discovery

    master

    The package provides utilities for preparing datasets before they are used in discovery algorithms.

    • DataProcessing: Provides tools for general data manipulation and preparation.
    • DataNormalization: Specifically handles the scaling and normalization of data to ensure numerical stability and consistent feature importance during the discovery process.
  11. Use DataDrivenSolution to manage discovery workflows

    master
    The DataDrivenSolution object is the primary container for managing the lifecycle of a data-driven differential equation discovery task. It encapsulates the problem definition, the basis used for discovery, the algorithm applied, and the resulting discovered model. Use it to track whether a discovery process has successfully converged via its return codes.