Art of DS

Appearance

Palette
Theme
Unlock $20 one time
Sign in, or create an account

Sign in to Art of DSCreate your Art of DS account

We email you a link and a six-digit code. Either one signs you in; there is no password.Enter your email. We send a link and a six-digit code to confirm it — no password to remember. The account is free.

  • You come back to this page, right where you were.
  • Already have an account? The same email simply signs you in.

By continuing you accept the Terms and the Privacy policy.

Your account

Free accountLifetime access

Machine learning · 7 compared

Linear model family

Definition

Every model here is the same weighted sum fitted by least squares — what separates them is the penalty added to the objective, and each penalty is a different claim about your features.

Comparison

Name What it changes Penalty Zeroes coefficients? Hyperparameters
Linear regression No penalty. Minimises squared error and nothing else, so it overfits freely when features are many or correlated. Full page →noneNonone
Ridge L2 penalty. Shrinks every coefficient smoothly, splitting effect across correlated features instead of playing them against each other. Full page →L2 — ‖w‖²Noalpha
Lasso L1 penalty. Drives weak coefficients to exactly zero, so fitting the model also selects the features. Full page →L1 — ‖w‖₁Yesalpha
Elastic Net Both penalties, weighted. Selects like Lasso while keeping correlated groups together like Ridge. Full page →L1 + L2Yesalpha, l1_ratio
Bayesian ridge L2 as a prior rather than a setting. Learns the penalty strength from the data and returns uncertainty with every prediction. Full page →L2, learnedNonone tuned
Polynomial Not a penalty but an expansion — adds powers and cross-terms so the same linear machinery fits a curve. Full page →none by itselfNodegree
Logistic Same weighted sum through a sigmoid, fitted by likelihood. Outputs a probability, so it classifies rather than predicts a quantity. Full page →L2 by defaultwith l1_ratioC, l1_ratio

On the cheat sheet: Linear models →

One model, several objectives

Every row above predicts with the same expression — a weighted sum of features plus an intercept. None of them differ in what they compute at prediction time. They differ in what they minimise at fitting time, and that is entirely a matter of which penalty is bolted onto the squared-error loss.

Elastic Net makes the relationship explicit, because it contains the other two: its objective carries both penalties weighted by l1_ratio, and at l1_ratio = 0 the penalty is purely L2 — Ridge — while at l1_ratio = 1 it is purely L1 — Lasso [1, l1_ratio]. Ridge and Lasso are not siblings of Elastic Net so much as its endpoints.

Choosing is a claim about your features

The decision is not "which performs best" but "what do I believe is true":

  • Most features carry a little signal → Ridge. Nothing is discarded, everything is quietened.
  • Most features are irrelevant → Lasso. L1 "results in a solution that is more sparse" [2, §7.1.2]. Sparsity is an assumption, and the model will act on it.
  • Relevant features come in correlated groups → Elastic Net. Lasso would keep one of each group arbitrarily; the L2 component stops that.
  • I do not want to tune anything and I need uncertainty → Bayesian ridge.

If you are unsure, Elastic Net can reach any of the three by search — at the cost of a second hyperparameter, l1_ratio [1, l1_ratio].

The two that are not penalties

Two rows break the pattern and are worth separating out.

Polynomial regression changes the features, not the objective. It is a preprocessing step that hands ordinary least squares a wider matrix, and it adds capacity rather than removing it — which is why it is almost always paired with a penalty rather than used alone.

Logistic regression changes the task. It is the only row that does not predict a quantity: the weighted sum goes through a sigmoid and comes out as a probability. Its penalty parameter also runs backwards — C is the inverse of regularization strength, where Ridge and Lasso use alpha directly.

Practical advice

Scale your features before any of the penalised rows. All of these penalties act on raw coefficient magnitude, and coefficient magnitude depends on units — so without a scaler you are penalising features for being measured in millimetres.

Tune with the built-in cross-validated variants (RidgeCV, LassoCV, ElasticNetCV) rather than a hand-rolled grid. They exploit the regularization path and are substantially faster than refitting from scratch at every value.

Sources

  1. scikit-learn — sklearn.linear_model.ElasticNetdocs · retrieved 2026-08-31https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html
  2. Goodfellow, Bengio, Courville. Deep Learning (2016)bookhttps://www.deeplearningbook.org/contents/regularization.html

Have a promo code?

A code that takes 100% off unlocks everything at once. A smaller one takes its share off the price in the payment window: enter the same code there.

Write to support

A question, a problem with access, a refund? Write to us and we answer by email.

What is it about?

Your address is used only to answer you.

Message sent

Thank you. We will reply to the address you gave, by email.

Or write to us directly

support@artofds.com

Message sent Thank you. We will reply to the address you gave, by email.

Check the email address: we need it to reply.

That is our own address. Enter yours, so the reply reaches you.

This address cannot receive email. Check it for a typo.

Write a little more: at least 10 characters.

Too many messages in a short time. Try again in a few minutes.

The message could not be sent. Please write to us directly: support@artofds.com