The Hong Kong Polytechnic University · FACULTY OF COMPUTER SCIENCE

BME5150 Chap.5 Ridge, Lasso and Elastic Net

- one subject, every graph, every model, every mark
6 Chapters2-page Bible
Our own words - no uploaded lecturer files
Updated for this semester
Chapter 5 of 7 · BME5150

Ridge, Lasso and Elastic Net

Regularisation changes the fitting objective

Least squares rewards close fit to development outcomes. Regularisation adds a cost for coefficient size. Lambda controls how strongly that cost competes with fit. At zero, the solution matches the unpenalised fit.

As lambda increases, coefficients shrink, training error usually rises and held-out stability may improve.

Ridge uses an L2 penalty

Ridge adds the sum of squared coefficients. Squaring makes a large coefficient contribute strongly to the penalty. Correlated predictors often share influence and coefficients typically approach zero without becoming exactly zero.

Ridge can stabilise predictions when many variables contain overlapping information.

Lasso uses an L1 penalty

Lasso adds the sum of absolute coefficient values. Its geometry permits coefficients to reach exactly zero, creating a sparse predictive model. Which variable survives among correlated alternatives can change with the sample.

A zero coefficient therefore means the fitted specification did not retain that variable, not that the underlying phenomenon is absent.

Elastic net combines both behaviours

Elastic net mixes L1 and L2 penalties. It can retain grouped shrinkage while still producing sparsity. The mixing parameter and lambda both require tuning.

That flexibility is useful for correlated radiomic features and increases the need for nested development resampling.

Scaling and validation complete the method

Penalties act on coefficient magnitudes, so predictors need comparable treatment. Fit scaling within training data.

Choose lambda from held-out development folds rather than training loss, refit the selected specification on all development cases and evaluate the locked pipeline once.

In this chapter

What this chapter covers

  • 01

    Penalised regression objectives

  • 02

    Lambda and coefficient shrinkage

  • 03

    Ridge L2 behaviour

  • 04

    Lasso L1 sparsity

  • 05

    Elastic net mixing

  • 06

    Scaling, tuning and selection stability

Worked example · free

Compare L1 and L2 penalty shapes

Q [8 marks]. AskSia-authored practice. Two standardised coefficients are 3 and −1, with lambda 0.2. Calculate the ridge and lasso penalty contributions before refitting, then explain what the comparison does and does not establish. The marks shown are an AskSia study allocation, not a University marking scheme.
The blue ridge paths approach zero smoothly, while the orange lasso paths hit zero and remain there as lambda increases.The blue ridge paths approach zero smoothly, while the orange lasso paths hit zero and remain there as lambda increases.Penalty strength λCoefficientridge approaches zerolasso reaches zeroCoordinates encode stronger shrinkage as λ moves right
The blue ridge paths approach zero smoothly, while the orange lasso paths hit zero and remain there as lambda increases.
  • 3Compute squared and absolute coefficient sums.
  • 2Multiply each by lambda.
  • 3Interpret the penalty shapes without comparing tuned lambda scales directly.
The ridge sum is 3² + (−1)² = 10, so its contribution is 0.2 × 10 = 2. The lasso sum is |3| + |−1| = 4, giving 0.2 × 4 = 0.8. The arithmetic shows that L2 gives the larger coefficient disproportionate influence while L1 grows linearly. It does not show which fitted model is more regularised, because coefficients and useful lambda scales change under each objective.
Sia tip — Explain penalty geometry first; select lambda from held-out development performance rather than matching its printed value across methods.
Glossary

Key terms

Regularisation
Regularisation adds a complexity penalty to a fitting objective to improve generalisation.
Lambda
Lambda controls the strength of the penalty relative to model fit.
L2 Penalty
An L2 penalty sums squared coefficients and produces continuous shrinkage.
L1 Penalty
An L1 penalty sums absolute coefficients and can produce exact zeros.
Elastic Net
Elastic net combines L1 and L2 penalties through a tuned mixture.
FAQ

Ridge, Lasso and Elastic Net FAQ

Why should predictors be scaled before ridge or lasso?

Penalty size depends on coefficient magnitude, and coefficient magnitude depends on predictor units. Without deliberate scaling, the model penalises variables differently for unit reasons. Fit scaling within each development fold and apply the stored parameters to held-out data.

Does lasso prove that a removed feature is unimportant?

No. It shows that one fitted penalised specification did not retain the feature under a chosen scale, lambda and set of correlated alternatives. Check how often the feature survives resampling and use independent evidence for biological importance.

How should lambda be chosen?

Choose lambda by the metric that matches the task within development cross-validation. Training loss usually favours too little penalty. After selection, refit the complete specification on development data and apply it once to the untouched evaluation set.

Study strategy

Assessment move

Draw four coefficient paths as lambda moves right: two ridge paths approaching zero and two lasso paths reaching zero. Explain why the picture changes only after predictors are placed on a comparable scale. Recompute L1 and L2 penalties for small coefficient vectors until the effect of squaring is immediate. Then practise the valid workflow from split through nested scaling and tuning to final evaluation.

For interpretation, take one variable selected by lasso and write a safe predictive statement, a stability question and a biological claim that would require separate evidence. Finish by explaining when elastic net might be preferred for groups of correlated radiomic features. Compare the selected feature set across imagined folds and decide what selection frequency would make you cautious.

The point is to distinguish sparse prediction from a stable scientific signature.

Working through Ridge, Lasso and Elastic Net in BME5150? Sia is AskSia’s AI Computer Science tutor — ask any BME5150 Ridge, Lasso and Elastic Net question and get a clear, step-by-step explanation grounded in how BME5150 is taught and assessed. Read this chapter free, then take your hardest questions to Sia.

A+Everything unlocked
Unlocks this Bible + all 16 of your The Hong Kong Polytechnic University subjects - and 1,000+ Bibles across every Australian university.
Sia - your BME5150 tutor, unlimited, worked the way the exam marks it
The full 2-page Bible + practice bank with worked solutions
Chrome extension - sync your LMS so Sia knows your deadlines
Bilingual EN / Chinese on every Bible and every Sia answer
$0.99 Trial
30-day money-back · cancel in one tap · how it works