uf3.regression.regularize.get_penalty_matrix_2D¶
- get_penalty_matrix_2D(L: int, M: int, ridge: float = 0.0, curvature: float = 1.0) numpy.ndarray[source]¶
- Generates additive regularization matrix for linear regression
using curvature penalty and/or L2 (ridge) penalty. Curvature penalty here applies to coefficients that are spatially related in two dimensions that may not be adjacent after flattening for linear least-squares.
- Parameters
L (int) – length of coefficient matrix before flattening.
M (int) – width of coefficient matrix before flattening.
ridge (float) – L2 (ridge) regularization strength.
curvature (float) – Local curvature regularization strength.
- Returns
- square penalty matrix for linear
least-squares of shape (L*M , L*M).
- Return type
matrix_2d (numpy.ndarray)