How this calculation works
Penalized regression trades fit against coefficient size. This single page covers ridge, lasso and elastic net through one explicit mixture parameter, with an automatic unpenalized intercept. Coordinate descent uses centered predictors, optional standardization and a KKT residual check before returning raw-coordinate coefficients.
SSE/(2n)+lambda[alpha ||beta||1+(1−alpha)||beta||2²/2].A worked example
For x=−2,−1,0,1,2 and y=2x, use lambda one, mix zero and centering without standardization. The ridge slope is 4/3 and intercept zero. SSE is 40/9; SSE/(2n) plus the penalty gives objective 4/3. An unpenalized slope would be two.
Good to know
3–200 matched observations, up to six nonconstant predictors. The selected scaling changes the penalty meaning. Convergence and KKT checks are required. No automatic lambda search, confidence intervals or separate duplicate ridge/lasso pages.
Reference: Scikit-learn elastic net objective (opens in a new tab) ↗
One objective covers three penalties
Ridge uses a squared coefficient penalty, lasso an absolute coefficient penalty, and elastic net a mixture of both. Keeping them on one page makes their shared loss normalization explicit. The printed objective divides residual sum of squares by twice the observation count, which matters when comparing lambda values.
The intercept is recovered after centering and is never penalized. A constant predictor duplicates that intercept and is rejected. Centering does not force the final raw-coordinate intercept to zero; it separates location from slope shrinkage, then maps the fitted model back to the original predictor coordinates.
The Weighted polynomial regression calculator covers the nearby task. Existing weighted polynomial fit has no coefficient penalties or general multicolumn design.
Scaling changes the shrinkage question
With standardization enabled, each predictor is divided by its population standard deviation before penalties are applied. The raw coefficients are then converted back. Equal numeric lambda values across standardized and unstandardized fits generally represent different penalties on the original physical variables, so matching those values alone is insufficient.
Coordinate descent repeatedly updates one coefficient using the current partial residual. For lasso-containing fits, soft thresholding can set a coefficient exactly to zero. A zero coefficient is an optimization outcome under the chosen penalty, not proof that its corresponding variable has no scientific or causal association with the response. Near a threshold, small changes in lambda can change which coefficients are exactly zero.
KKT checks certify the fitted optimization conditions
The maximum KKT violation checks both active coefficients and zero coefficients against their appropriate stationarity conditions. A small iterate change without that check could hide a stalled fit. The page rejects runs that fail the numerical convergence or KKT thresholds rather than displaying an unsupported optimum label.
Choosing lambda or the mixture from the same sample can introduce selection bias. This calculator keeps those parameters manual and provides no cross-validation score, automatic model selection or post-selection confidence interval. Independent reference checks match the exact objective and scaling conventions before comparing fitted coefficients or loss values.
Read the exact penalty convention
The objective here is SSE/(2n)+λ[αΣ|βj|+(1−α)Σβj²/2]. The mixing control α=0 gives ridge, α=1 gives lasso, and an intermediate value combines them. The automatically fitted intercept is unpenalized. Some packages use the name alpha for the overall penalty rather than the mixing fraction, so match the printed objective before comparing settings across software.
The division by n matters: a λ chosen for an unnormalized SSE objective is not numerically equivalent to the same λ here. Penalties also depend on predictor units. Standardizing changes the optimization problem before coefficients are converted back to the original coordinate scale, so two runs with different scaling choices are not expected to have identical slopes.
Trace the default slope under ridge and lasso
With x=−2,−1,0,1,2 and y=2x, both means are zero and Σx²/n=2. Without predictor scaling and with λ=1, ridge solves (2+1)β=4, giving β=4/3. The intercept remains zero. The smaller slope trades extra residual error for a smaller squared coefficient penalty.
For lasso at the same λ, soft thresholding gives β=(4−1)/2=1.5. With mixing α=0.5, β=(4−0.5)/(2+0.5)=1.4. These one-predictor calculations show why a larger mixing fraction need not give a smaller nonzero slope at fixed λ: the shape of the penalty changes as well as the amount of thresholding.
Use the optimality residual as a numerical check
Coordinate descent updates one coefficient while holding the others fixed. At convergence, a nonzero coefficient balances the residual gradient against its penalty derivative. A zero lasso coefficient instead satisfies a gradient interval condition. The reported KKT residual summarizes departures from these conditions; it helps detect an incomplete solve rather than measuring prediction quality.
A small KKT residual means the stated convex problem has been solved accurately within numerical tolerance. It does not identify the best λ for new data. Select tuning parameters through an appropriate validation design outside this page, preserving time order or groups when needed. Do not choose the setting solely because its training SSE is smallest: less regularization will often win that comparison.
Interpret zero and correlated coefficients carefully
A lasso zero means the fitted penalized optimum omitted that predictor at the chosen penalty and scaling. It is not a hypothesis-test result establishing no association. Highly correlated columns can substitute for each other, and small data changes may alter which one receives the nonzero coefficient. Ridge tends to distribute weight across correlated columns rather than select one.
Elastic net can retain groups of correlated predictors, but it cannot manufacture information absent from the design. Before interpreting a coefficient, check measurement units, coding, redundancy and outliers. Use an unpenalized inferential model only when its assumptions and study question warrant it; this calculator does not attach conventional least-squares p-values to penalized estimates.
A few questions, answered
What does mix zero mean?
It selects ridge; mix one selects lasso and intermediate values give elastic net.
Is the intercept penalized?
No. It is fitted through centering and recovered in original coordinates.
Does this form add an intercept?
Yes. It centers the fitting problem and returns an unpenalized intercept. Do not add a constant predictor column; predictors must have nonzero spread.
Does a lasso zero prove a variable is irrelevant?
No. It is a consequence of the selected penalty, scaling and competing predictors, not a significance test or a causal conclusion.