fit()#

_NonparametricModel.fit(states, lhs, inputs=None, solver=None)[source]#

Learn the model operators from data.

The operators are inferred by solving the regression problem

\[\min_{\Ohat}\sum_{j=0}^{k-1}\left\| \fhat(\qhat_j, \u_j) - \zhat_j \right\|_2^2 = \min_{\Ohat}\left\|\D\Ohat\trp - \dot{\Qhat}\trp\right\|_F^2\]

where \(\zhat = \fhat(\qhat, \u)\) is the model and

  • \(\qhat_j\in\RR^r\) is a measurement of the state,

  • \(\u_j\in\RR^m\) is a measurement of the input, and

  • \(\zhat_j\in\RR^r\) is a measurement of the left-hand side of the model.

The operator matrix \(\Ohat\in\RR^{r\times d(r,m)}\) is such that \(\fhat(\q,\u) = \Ohat\d(\qhat,\u)\) for some data vector \(\d(\qhat,\u)\in\RR^{d(r,m)}\); the data matrix \(\D\in\RR^{k\times d(r,m)}\) is given by \([~\d(\qhat_0,\u_0)~~\cdots~~\d(\qhat_{k-1},\u_{k-1})~]\trp\). Finally, \(\Zhat = [~\zhat_0~~\cdots~~\zhat_{k-1}~]\in\RR^{r\times k}\). See the opinf.operators module for more explanation.

The strategy for solving the regression, as well as any additional regularization or constraints, are specified by the solver.

Parameters
states(r, k) ndarray

Snapshot training data. Each column is a single snapshot.

lhs(r, k) ndarray

Left-hand side training data. Each column lhs[:, j] corresponds to the snapshot states[:, j]. The interpretation of this argument depends on the setting: forcing data for steady-state problems, next iteration for discrete-time problems, and time derivatives of the state for continuous-time problems.

inputs(m, k) or (k,) ndarray or None

Input training data. Each column inputs[:, j] corresponds to the snapshot states[:, j]. May be a one-dimensional array if m=1 (scalar input).

solveropinf.lstsq object or float > 0 or None

Solver for the least-squares regression. Defaults:

Returns
self