cherab.inversion.regularization.criteria.PRESSΒΆ
- class cherab.inversion.regularization.criteria.PRESSSourceΒΆ
Bases:
CriterionPredicted Residual Error Sum of Squares (PRESS) criterion.
The PRESS criterion, also known as ordinary cross-validation, selects the regularization parameter \(\lambda\) by minimizing the leave-one-out cross-validation error.
Note
The theory and implementation of the PRESS criterion are described in the PRESS theory page.
Methods
optimize(solver,Β bounds[,Β stepsize])Find the optimal parameter by minimizing PRESS with basinhopping.
Plot PRESS as a function of the regularization parameter.
press(solver,Β beta)Calculate the PRESS criterion function.
- press(solver: _SVDBase, beta: float) floatSourceΒΆ
Calculate the PRESS criterion function.
The PRESS function \(\mathcal{P}(\lambda)\) can be expressed with SVD components as:
\[\mathcal{P}(\lambda) = \left\| \left[ \mathrm{Diag}\!\left( \mathbf{I} - \mathbf{U}\mathbf{F}_\lambda\mathbf{U}^\mathsf{T} \right) \right]^{-1} \!\left( \mathbf{I} - \mathbf{U}\mathbf{F}_\lambda\mathbf{U}^\mathsf{T} \right)\hat{\mathbf{b}} \right\|_2^2,\]where \(\hat{\mathbf{b}} = \mathbf{B}\mathbf{b}\) (or simply \(\mathbf{b}\) when \(\mathbf{B} = \mathbf{I}\)) and \(\mathrm{Diag}(\mathbf{M})\) denotes the diagonal matrix formed from the diagonal entries of \(\mathbf{M}\).
-
optimize(solver: _SVDBase, bounds: tuple[float, float], stepsize: float =
10, **kwargs: Any) tuple[float, OptimizeResult]SourceΒΆ Find the optimal parameter by minimizing PRESS with basinhopping.
- Parameters:
- Returns:
lambda_opt (float) β Optimal regularization parameter.
result (
OptimizeResult) β Optimizer result object returned bybasinhopping.
-
plot_press(solver: _SVDBase | None =
None, axes: None =None, bounds: Collection[float | None] | None =None, n_beta: int =500, show_min_line: bool =True) tuple[Axes, Figure]SourceΒΆ -
plot_press(solver: _SVDBase | None =
None, axes: Axes | None =None, bounds: Collection[float | None] | None =None, n_beta: int =500, show_min_line: bool =True) Axes Plot PRESS as a function of the regularization parameter.
- Parameters:
- solver: _SVDBase | None =
NoneΒΆ An
_SVDBaseinstance. IfNone, the last solver used inoptimize()is used.- axes: None =
NoneΒΆ - axes: Axes | None =
None Matplotlib axes to plot on. If
None, a new figure and axes are created.- bounds: Collection[float | None] | None =
NoneΒΆ Boundary pair of log10 of regularization parameters, by default None. If None, the bounds are generated by the solver as described in
SVD._generate_bounds(). If you set the bounds like(-10, None), the higher bound is set to \(\log_{10}\sigma_1^2\). Raise an error if a >= b in (a, b).- n_beta: int =
500ΒΆ Number of regularization parameters, by default 500.
- show_min_line: bool =
TrueΒΆ Whether to show a vertical line at the optimal regularization parameter.
- solver: _SVDBase | None =
- Returns: