class SINDy¶
- class deeptime.sindy.SINDy(library=None, optimizer=None, input_features=None)¶
Learn a dynamical systems model for measurement data using the Sparse Identification of Nonlinear Dynamical Systems (SINDy) method.
For given measurement data \(X\), and a set of library functions evaluated on \(X\)
\[\Theta(X) = [\theta_1(X), \theta_2(X), \dots, \theta_k(X)], \]SINDy seeks a sparse set of coefficients \(\Xi\) which satisfies
\[\dot{X} \approx \Theta(X)\Xi. \]The i-th column of this matrix equation gives a differential equation for the i-th measurement variable (i-th column in \(X\)). For more details see [1].
- Parameters:
library (library object, optional, default=None) – The candidate feature library, \(\Theta\). The object should implement a
fit()
,transform()
, andget_feature_names_out()
methods. It should also haven_input_features_
andn_output_features_
attributes. By default a polynomial library of degree 2 is used.optimizer (optimizer object, optional, default=None) – The optimization routine used to solve the objective \(\dot{X} \approx \Theta(X)\Xi\). The object should have
fit()
andpredict()
methods andcoef_
andintercept_
attributes. For example, any linear regressor from sklearn.linear_model should work. By default,STLSQ()
is used.input_features (list of strings, optional, default=None) – List of input feature names. By default, the names “x0”, “x1”, …, “x{n_input_features}” is used.
References
Attributes
Property reporting whether this estimator contains an estimated model.
Shortcut to
fetch_model()
.Methods
Yields the latest model.
fit
(x[, y, t])Fit the estimator to measurement data.
fit_fetch
(data, **kwargs)Fits the internal model on data and subsequently fetches it in one call.
get_params
([deep])Get the parameters.
set_params
(**params)Set the parameters of this estimator.
- fetch_model() Optional[SINDyModel] ¶
Yields the latest model.
- Returns:
model – The model.
- Return type:
SINDyModel or None
- fit(x, y=None, t=None)¶
Fit the estimator to measurement data.
- Parameters:
x (np.ndarray, shape (n_samples, n_input_features)) – Training/measurement data. Each row should correspond to one example and each column to a feature.
y (np.ndarray, shape (n_samples, n_input_features), optional, default=None) – Array of derivatives of
x
. By default,np.gradient
is used to compute the derivatives.t (np.ndarray, shape (n_samples,) or a scalar, optional, default=None) – The times when the measurements in
x
were taken or the (uniform) time spacing between measurements inx
. By default a timestep of 1 is assumed. This argument is ignored ify
is passed.
- Returns:
self – Reference to self
- Return type:
- fit_fetch(data, **kwargs)¶
Fits the internal model on data and subsequently fetches it in one call.
- Parameters:
data (array_like) – Data that is used to fit the model.
**kwargs – Additional arguments to
fit()
.
- Returns:
The estimated model.
- Return type:
model
- get_params(deep=False)¶
Get the parameters.
- Returns:
params – Parameter names mapped to their values.
- Return type:
mapping of string to any
- set_params(**params)¶
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form
<component>__<parameter>
so that it’s possible to update each component of a nested object.- Parameters:
**params (dict) – Estimator parameters.
- Returns:
self – Estimator instance.
- Return type:
object
- property has_model: bool¶
Property reporting whether this estimator contains an estimated model. This assumes that the model is initialized with None otherwise.
- Type:
bool
- property model¶
Shortcut to
fetch_model()
.