Skip to main content

Module regression

Module regression 

Source
Expand description

Linear regression: ordinary least squares (OLS) and ridge (L2) regression.

Both estimators fit a coefficient vector β and an intercept by the normal equations. OLS minimises ‖y − Xβ‖²; ridge adds an L2 penalty λ‖β‖² on the slopes (the intercept is left unpenalised, matching scikit-learn’s Ridge). The fit centres the design and target, solves (X_cᵀX_c + λI)β = X_cᵀy_c for the centred slopes by Gaussian elimination with partial pivoting, and recovers the intercept from the column means. This base block backs RegressionMethod.

Structs§

LinearModel
A fitted linear model: an intercept plus one slope per predictor column.

Enums§

RegressionError
Errors that prevent a linear model from being fitted.

Functions§

ols
Fits an ordinary-least-squares linear model to x and y.
ridge
Fits a ridge (L2-regularised) linear model to x and y with penalty lambda.