pub struct ElasticNet {
pub coef: Array1<f64>,
pub intercept: f64,
pub alpha: f64,
pub l1_ratio: f64,
pub fit_intercept: bool,
pub n_iter: usize,
pub converged: bool,
}Expand description
Elastic-net penalised linear regression by coordinate descent.
l1_ratio ∈ [0, 1] mixes the two penalties:
α · (l1_ratio · ‖β‖₁ + ½ · (1 − l1_ratio) · ‖β‖²). l1_ratio = 1
reduces to Lasso; l1_ratio = 0 reduces to Ridge (though the
dedicated Ridge implementation is faster for that case).
Fields§
§coef: Array1<f64>Fitted coefficients.
intercept: f64Fitted intercept.
alpha: f64Penalty strength.
l1_ratio: f64L¹ vs L² mixing.
fit_intercept: boolWhether the fit included an intercept.
n_iter: usizeNumber of outer coordinate-descent sweeps that ran.
converged: boolWhether the final sweep’s max coordinate change fell below tol.
Implementations§
Source§impl ElasticNet
impl ElasticNet
Sourcepub fn fit(
y: ArrayView1<'_, f64>,
x: ArrayView2<'_, f64>,
alpha: f64,
l1_ratio: f64,
fit_intercept: bool,
) -> Result<Self>
pub fn fit( y: ArrayView1<'_, f64>, x: ArrayView2<'_, f64>, alpha: f64, l1_ratio: f64, fit_intercept: bool, ) -> Result<Self>
Fit with default settings.
Sourcepub fn fit_with(
y: ArrayView1<'_, f64>,
x: ArrayView2<'_, f64>,
alpha: f64,
l1_ratio: f64,
fit_intercept: bool,
max_iter: usize,
tol: f64,
) -> Result<Self>
pub fn fit_with( y: ArrayView1<'_, f64>, x: ArrayView2<'_, f64>, alpha: f64, l1_ratio: f64, fit_intercept: bool, max_iter: usize, tol: f64, ) -> Result<Self>
Full-configuration fit.
§Convergence
Coordinate descent on the ElasticNet objective is provably
convergent for alpha ≥ 0, l1_ratio ∈ [0, 1]. Convergence
is monitored via the maximum absolute change in any coordinate
across a full sweep; the fit terminates when this falls below
tol or max_iter sweeps have run (whichever first).