fit()#

DiscreteModel.fit(states, nextstates=None, inputs=None, solver=None, *, regularizer=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 - [~\zhat_0~~\cdots~~\zhat_{k-1}~]\trp \right\|_F^2\]

where \(\zhat_j = \fhat(\qhat_j, \u_j)\) 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 next state iteration after \(\qhat_j\),

  • \(\Ohat\in\RR^{r\times d(r,m)}\) is the operator matrix such that \(\fhat(\q,\u) = \Ohat\d(\qhat,\u)\) for some data vector \(\d(\qhat,\u)\in\RR^{d(r,m)}\), and

  • \(\D\in\RR^{k\times d(r,m)}\) is the data matrix given by \([~\d(\qhat_0,\u_0)~~\cdots~~\d(\qhat_{k-1},\u_{k-1})~]\trp\),

See the opinf.operators module for further 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.

nextstates(r, k) ndarray or None

Next iteration training data. Each column nextstates[:, j] is the iteration following states[:, j]. If None, use nextstates[:, j] = states[:, j+1].

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).

solverlstsq Solver object or float > 0 or None

Solver for the least-squares regression. Defaults:

Returns
self