Skip to main content

select_lambda_gcv

Function select_lambda_gcv 

Source
pub fn select_lambda_gcv(
    x: Array2<f64>,
    y: Array1<f64>,
    lambdas: &[f64],
) -> Result<RidgeFit>
Expand description

Select the ridge penalty that minimizes GCV over a grid of candidate λs, returning the best RidgeFit.

Refits at each candidate (each fit is a single SVD-based closed-form solve) and keeps the one with the smallest RidgeFit::gcv. The grid is the caller’s to choose — a geometric sweep such as 10.^{-3..3} is typical.

§Errors

RegressionError::InvalidParameter if lambdas is empty; otherwise any error from RidgeFit::new.