Understand the idea
Ordinary regression gives every predictor you include a nonzero coefficient, whether or not it truly matters. Lasso regression adds a penalty for having large coefficients at all, and because of the particular geometric shape of that penalty (imagine a diamond rather than a circle), the optimal fit very often lands exactly on a corner of that shape, which means some coefficients get pushed all the way to EXACTLY zero, not just shrunk smaller. Those zeroed-out predictors are effectively dropped from the model.
This is why lasso is described as doing automatic feature selection: instead of you deciding by hand which predictors to keep, the penalty itself decides, and you read off which predictors survived with nonzero coefficients as the ones the model judged worth keeping. Turn the penalty strength up and fewer predictors survive; turn it all the way up and every coefficient vanishes, leaving just the overall average of the outcome.
A predictor being kept is not proof it truly matters, and a predictor being zeroed out is not proof it doesn't: lasso's selection can be UNSTABLE when predictors are correlated with each other, sometimes arbitrarily keeping one out of a group of similar predictors and dropping the rest. And because the penalty deliberately distorts coefficients toward zero, this model does not produce the p-values and confidence intervals ordinary regression gives you.
Lasso stands for least absolute shrinkage and selection operator; it uses L1 regularization, a penalty on the size of the coefficients that can shrink some of them exactly to zero.
Practitioner explanation
KernelStats fits scikit-learn's Lasso/LassoCV, which minimizes (1/(2n))*sum((y-y-hat)^2) + alpha*sum(|beta_j|) (the 1/(2n) scaling is what gives alpha its meaning, matching glmnet's lambda), standardizing predictors by default (so the penalty treats every predictor's scale fairly) and reporting coefficients per one-SD change. The penalty strength alpha is chosen by K-FOLD CROSS-VALIDATION by default (LassoCV, the same idea as glmnet's cv.glmnet): the auto-generated lambda path is scored and the value minimizing out-of-sample error is kept, with the validation curve (CV error vs. lambda, chosen value marked) shown on the card. This is explicitly what prevents the classic failure mode of an arbitrarily chosen fixed alpha (e.g. alpha=1) driving EVERY coefficient to zero and leaving an empty model; manual lambda selection remains available as an option.
As with ridge and elastic net, this penalized estimator produces NO valid classical p-values or standard errors: the L1 penalty deliberately biases coefficients toward (and onto) zero, which breaks the sampling-theory assumptions ordinary least-squares inference depends on. The product's own guidance for formal inference is explicit and carries its own caveat: refit ordinary least squares on ONLY the lasso-selected predictors if you need p-values, but remember the post-selection-inference problem; reusing the same data to both select which variables matter and then test them understates the true uncertainty in that subsequent test.
With highly correlated predictors, lasso tends to keep ONE from a correlated group and drop the rest, somewhat arbitrarily (a different random sample of the same underlying data could easily have kept a different member of the group instead); this is presented as a specific, known instability rather than a hidden gotcha, and Elastic Net is offered as the direct remedy when correlated predictor groups are expected.
When to use it
Consider it when
You want to predict a continuous outcome and expect that only a handful of the available predictors truly matter, and want the model itself to select which ones by driving the rest to exactly zero.
Use caution when
Predictors are highly correlated in groups you want kept or dropped together (lasso's selection among correlated predictors is unstable and somewhat arbitrary; use Elastic Net), or you need valid p-values and confidence intervals on individual coefficients (refit ordinary least squares on the selected predictors, with the post-selection-inference caveat in mind, or use ordinary linear regression from the start).
Formulas and symbols
Lasso objective
n the number of rows; alpha the penalty strength, chosen by cross-validation by default. The L1 penalty (sum of absolute coefficients) is what drives some coefficients to exactly zero.
R-squared and RMSE
Descriptive fit measures reported alongside the selected coefficients; not accompanied by p-values.
Assumptions and checks
- Linearity. Lasso regression models the outcome as a LINEAR function of the (possibly transformed) predictors; genuine curvature in the true relationship is not captured and biases predictions systematically in regions where the relationship bends.
In KernelStats: Not checked by KernelStats: no residual or linearity diagnostic is run for this method, unlike Linear Regression's diagnostics; inspect residual plots manually or compare against a nonlinear alternative (e.g. Generalized Additive Model (GAM), Spline Regression).
- Normality (of residuals, not of the raw data). Any informal reading of the coefficient path implicitly leans on the same normal-errors assumption as ordinary least squares; non-normal or heteroscedastic residuals are not flagged here the way they are for Linear Regression.
In KernelStats: Not checked by KernelStats: no residual normality or homoscedasticity diagnostic is computed for this method.
- Among a group of strongly correlated predictors, lasso's L1 penalty tends to keep roughly one and zero out the rest somewhat arbitrarily; the surviving predictor is not necessarily the causally 'correct' one, just one workable representative of the group, and a slightly different sample could select a different member of the same group.
In KernelStats: Not checked by KernelStats: no stability-selection or bootstrap check of which predictors survive is run; compare against Ridge Regression (which shrinks correlated predictors together instead of selecting among them) if the exact identity of the surviving predictor matters.
- The regularization strength (alpha) is chosen by the analyst or by an internal cross-validation search; a poorly chosen or poorly validated alpha can under- or over-shrink the coefficients, changing which predictors are selected.
In KernelStats: Not checked by KernelStats as a formal assumption row: the chosen alpha and the resulting coefficients are reported directly; compare against Cross-Validated Model Comparison for an honest cross-validated comparison across model families.
Alternatives
- Elastic Net Regression. Predictors come in correlated groups: the added L2 component keeps or drops correlated predictors together rather than arbitrarily favoring one.
- Ridge Regression. You want to keep every predictor in the model (no feature selection) and only shrink coefficients for stability.
- Stepwise Model Selection. You want a classical, stepwise feature-selection procedure with p-value-based criteria rather than a penalized continuous shrinkage path.
Worked example
Scenario
Predicting penguin body mass from bill length, bill depth and flipper length (standardized), with lambda chosen by 5-fold cross-validation. Only numeric predictors are accepted; a text column such as sex is refused until it is encoded.
Result
Cross-validation selects lambda = 1.61; no coefficient is driven exactly to zero, but flipper length dominates (+702 g per SD) while bill depth (+36 g) and bill length (+23 g) are shrunk close to zero; R-squared = 0.76.
Interpretation
Almost all of the predictive signal runs through flipper length; the two bill measurements add little once it is in the model. The cross-validated lambda did not zero them, which is a reminder that lasso selection depends on where lambda lands: a slightly larger penalty would drop them, and neither outcome is a verdict on whether bill size is related to body mass in general.
Dataset: penguins.csv
Common misconceptions
Misconception
A predictor lasso keeps (nonzero coefficient) is proven to matter, and one it drops (zero coefficient) is proven not to.
Correction
Lasso's selection is UNSTABLE under collinearity: among a group of correlated predictors, it can arbitrarily keep one and drop the rest, and a slightly different sample could easily have kept a different member of that same group. Keeping or dropping a predictor reflects the penalty's geometry interacting with THIS sample's correlations, not a proven verdict about that predictor's real-world importance.
Misconception
The coefficients lasso reports come with the same kind of p-values as ordinary regression coefficients.
Correction
The L1 penalty deliberately biases coefficients toward (and onto) zero specifically to achieve feature selection, which breaks the classical sampling-distribution assumptions behind ordinary least-squares inference. There is no valid p-value for a lasso coefficient as reported here; formal inference requires refitting OLS on the selected predictors (with the post-selection-inference caveat) or using an unpenalized model from the start.
References
- Regression shrinkage and selection via the lasso, Tibshirani, R. (1996), Journal of the Royal Statistical Society, Series B, 58(1), 267-288.
- An Introduction to Statistical Learning with Applications in R (2nd ed.), Chapter 6, James, G., Witten, D., Hastie, T. and Tibshirani, R. (2021).
