Ordinary Least Squares and Regularization
For design matrix , targets , and coefficient vector , ordinary least squares (OLS) solves
The pseudoinverse gives a least-squares solution, . When columns of are nearly linearly dependent, small changes in the data can produce large coefficient changes. Prediction may remain acceptable while individual coefficients become unstable.
Penalized Objectives
Ridge
Ridge shrinks correlated or weakly identified coefficients and usually keeps all of them nonzero.
Lasso
The penalty can set coefficients exactly to zero. That sparsity is a property of the fitted objective, not proof that the selected variables are uniquely important or causal. With strongly correlated features, the selected member may be unstable.
Elastic Net
Elastic Net combines sparsity with Ridge-style stabilization and is often useful when predictors occur in correlated groups.
Working Rules
- Fit scaling and basis transformations on training data only; apply the recorded transformation to validation and test data.
- Do not penalize the intercept unless the formulation explicitly intends it.
- Select and using validation or cross-validation inside the training process.
- Compare predictive error, coefficient stability, and operational simplicity—not training loss alone.
- Use robust or quantile objectives when squared error does not represent the desired target or error cost.
- Separate predictive modeling from inferential claims; uncertainty estimates require explicit assumptions about the data-generating process.
Polynomial and interaction features can make the input relationship nonlinear while the fitted coefficients remain linear. The resulting model still inherits extrapolation and overfitting risks from the chosen basis.
See the scikit-learn linear-model guide for current solvers and estimator APIs.