cherab.inversion.regularization.GCVΒΆ
- class cherab.inversion.regularization.GCVSourceΒΆ
Bases:
CriterionGeneralized Cross-Validation (GCV) criterion.
Note
The theory and implementation of GCV criterion can be seen here.
Methods
gcv(solver,Β beta)Calculate of GCV criterion function.
optimize(solver,Β bounds[,Β stepsize])Find the optimal parameter by minimizing GCV with basinhopping.
plot_gcv()Plot GCV as a function of the regularization parameter.
- gcv(solver: _SVDBase, beta: float) floatSourceΒΆ
Calculate of GCV criterion function.
GCV function \(\mathcal{G}(\lambda)\) can be expressed with SVD components as:
\[\mathcal{G}(\lambda) = \frac{\rho}{\left[r - \sum_{i=1}^r f_{\lambda, i}\right]^2}.\]
-
optimize(solver: _SVDBase, bounds: tuple[float, float], stepsize: float =
10, **kwargs: Any) tuple[float, OptimizeResult]SourceΒΆ Find the optimal parameter by minimizing GCV with basinhopping.
- Parameters:
- Returns:
lambda_opt (float) β Optimal regularization parameter.
result (
OptimizeResult) β Optimizer result object returned bybasinhopping.
-
plot_gcv(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_gcv(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 GCV 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: