L2Solver#

class L2Solver(regularizer, lapack_driver: str = 'gesdd')[source]#

Solve the Frobenius-norm ordinary least-squares problem with \(L_2\) regularization.

That is, solve

\[\argmin_{\Ohat}\|\D\Ohat\trp - \Z\trp\|_F^2 + \|\lambda\Ohat\trp\|_F^2\]

for some specified \(\lambda \ge 0\).

The exact solution is described by the normal equations:

\[(\D\trp\D + \lambda^2\I)\Ohat\trp = \D\trp\Z\trp,\]

that is,

\[\Ohat = \Z\D(\D\trp\D + \lambda^2\I)^{-\mathsf{T}}.\]

Instead of solving these equations directly, the solution is calculated using the singular value decomposition of the data matrix \(\D\): if \(\D = \bfPhi\bfSigma\bfPsi\trp\), then \(\Ohat\trp = \bfPsi\bfSigma^{*}\bfPhi\trp\Z\trp\) (i.e., \(\Ohat = \Z\bfPhi\bfSigma^{*}\bfPsi\trp\)), where \(\bfSigma^{*}\) is a diagonal matrix with \(i\)-th diagonal entry \(\Sigma_{i,i}^{*} = \Sigma_{i,i}/(\Sigma_{i,i}^{2} + \lambda^2).\)

Parameters:
regularizerfloat

Scalar \(L_2\) regularization constant.

lapack_driverstr

LAPACK routine for computing the singular value decomposition. See scipy.linalg.svd().

Properties:
d#

Number of unknowns in each row of the operator matrix (number of columns of \(\D\) and \(\Ohat\)).

data_matrix#

\(k \times d\) data matrix \(\D\).

k#

Number of equations in the least-squares problem (number of rows of \(\D\) and number of columns of \(\Z\)).

lhs_matrix#

\(r \times k\) left-hand side data \(\Z\).

options#

Keyword arguments for scipy.linalg.svd(). These cannot be changed after instantiation.

r#

Number of operator matrix rows to learn (number of rows of \(\Z\) and \(\Ohat\))

regularizer#

Scalar \(L_2\) regularization constant \(\lambda > 0.\)

Methods:

cond

Compute the \(2\)-norm condition number of the data matrix \(\D\).

copy

Make a copy of the solver.

fit

Verify dimensions and compute the singular value decomposition of the data matrix in preparation to solve the least-squares problem.

load

Load a serialized solver from an HDF5 file, created previously from the save() method.

regcond

Compute the \(2\)-norm condition number of the regularized data matrix \([~\D\trp~~\lambda\I~]\trp.\)

regresidual

Compute the residual of the regularized regression objective for each row of the given operator matrix.

residual

Compute the residual of the \(2\)-norm regression objective for each row of the given operator matrix.

save

Serialize the solver, saving it in HDF5 format.

solve

Solve the Operator Inference regression.

verify

Verify the solver.