L2Solver#
- class L2Solver(regularizer=0)[source]#
Solve the l2-norm ordinary least-squares problem with L2 regularization:
sum_{i} min_{x_i} ||Ax_i - b_i||_2^2 + ||λx_i||_2^2, λ ≥ 0,
or, written in the Frobenius norm,
min_{X} ||AX - B||_F^2 + ||λX||_F^2, λ ≥ 0.
The solution is calculated using the singular value decomposition of A: If A = U Σ V^T, then X = V Σinv(λ) U^T B, where Σinv(λ)[i, i] = Σ[i, i] / (Σ[i, i]^2 + λ^2).
Properties
A
Left-hand side data matrix.
B
"Right-hand side matrix B = [ b_1 | .
d
Number of unknowns to learn in each problem (number of columns of A).
k
Number of equations in the least-squares problem (number of rows of A).
r
Number of independent least-squares problems (number of columns of B).
regularizer
Regularization scalar, matrix, or list of these.
Methods
Calculate the 2-norm condition number of the data matrix A.
Take the SVD of A in preparation to solve the least-squares problem.
Calculate the data misfit (residual) of the non-regularized problem for each column of B = [ b_1 | .
Solve the regularized least-squares problem.
Compute the 2-norm condition number of the regularized data matrix.
Calculate the residual of the regularized problem for each column of B = [ b_1 | .