parallax background

All Types of Regression

XGBoost, Unpacked: Why It Often Rules Kaggle
XGBoost, why It Rules Kaggle!
%alireza rashidi data science%
Vector DB


The Spectrum of Regression — Six Types Every Data Scientist Should Know
Machine Learning Fundamentals

Regression is not one tool. It is a spectrum.

Regression is the mathematical art of prediction — estimating how X impacts Y. From simple trends to complex decision boundaries, these are the six fundamental types every data scientist should master, each one a tool designed for a specific kind of chaos.

The charts on this page are hand-drawn teaching illustrations: small, honest datasets that show the shape of each idea rather than benchmark scores.

In this piece
  1. The philosophy of prediction — why one tool never fits
  2. The six types — what each one is really for
  3. The cheat sheet — match problem shape to method
  4. How I would choose — a four-step workflow
  5. Sources — the papers behind the methods
01Overview

The philosophy of prediction#

If we can mathematically define how variables relate, we gain the superpower of prediction — forecasting prices, estimating risk, scoring probabilities. But the world is rarely simple: relationships curve, data is noisy, and outliers mislead. Choosing the wrong technique is like cutting steak with a spoon. The name itself is a piece of history: Francis Galton coined “regression” in 1886, watching the heights of children drift back toward the average — regression toward the mean.[1]

LinearA straight line for additive relationships — fast, interpretable, honest.
PolynomialAdds powers of X so the line can bend with growth.
LogisticSquashes output into a 0–1 probability for Yes/No decisions.
RidgeL2 penalty shrinks coefficients to tame correlated noise.
LassoL1 penalty deletes useless features entirely.
Elastic NetBlends L1 + L2 for messy, high-dimensional data.
02The six types

What each one is really for#

Instead of formulas first, here is the practical version: what each technique assumes, where it breaks, and the kind of problem that makes it shine.

Linear Regression is the simplest form of regression, built on the least-squares method Adrien-Marie Legendre published in 1805.[1] Its core assumption is elegance: the relationship between your input (X) and your output (Y) can be described by a straight line.

The algorithm finds the Line of Best Fit by minimising the Sum of Squared Errors — making the total distance between the data points and the line as small as possible. While basic, it is incredibly powerful for interpretation: the slope tells you exactly how much Y changes for every unit increase in X.

Best when the relationship is genuinely additive and you need coefficients you can explain.Think pricing, forecasting, and quick baselines.
Price = (Price_per_sqft × Size) + Base_Price

🏠 Use case — real estate pricing. Generally, as size increases, price increases consistently. A 2,000 sq ft house is usually double the price of a 1,000 sq ft house (all else equal). The relationship is additive and linear.

The line of best fit
The “Line of Best Fit” minimises the total squared distance to every point.

How to read this: the algorithm tried every possible line and kept the one with the smallest total squared error.

What happens when the data curves, accelerates, or fluctuates? Fit a straight line to curved data and you get a high error rate — underfitting.

Polynomial Regression upgrades the linear equation with exponents (X², X³). A quadratic term creates a U-shape; a cubic creates an S-shape. That flexibility captures complex growth patterns, biological phenomena, and physics trajectories.

Best when growth compounds — the curve knows the straight line is lying.Think adoption curves, biology, physics.

🦠 Use case — epidemic growth. A virus spreads exponentially (1 person infects 2, who infect 4, who infect 8). A straight line would massively underestimate the danger; squared and cubed terms capture the rapid acceleration of cases.

Fitting the bend
Adding X² and X³ terms lets the line bend to follow accelerating growth.

How to read this: the model is still linear in its coefficients — only the input features gained powers. The danger is the opposite cliff: too many powers and the curve memorises noise.

Logistic Regression is not used to predict continuous numbers like price or temperature, but categories: Yes/No, True/False, Spam/Not Spam.

It predicts the probability of an event. Because probability must live between 0 and 1, a straight line fails (it runs to infinity). Instead, the sigmoid function squashes the output into an S-curve that stays neatly inside [0, 1].

Best when you need a defensible probability, not just a label.Think spam, churn, default risk, diagnosis screening.

📧 Use case — spam detection. We don’t want “this email is 500% spam” — mathematically impossible. We want “there is a 99% probability this is spam.” Logistic Regression provides that score, which you threshold (e.g. > 50% = spam).

The sigmoid boundary
The sigmoid squashes any score into a probability between 0 and 1.

How to read this: green points are class 0, purple points class 1. The curve is the model’s probability — steep where the classes separate, flat where it is certain.

Sometimes a model memorises the noise instead of learning the pattern — overfitting. It happens often when many variables are correlated (multicollinearity).

Ridge adds a penalty to the size of the coefficients: minimise error plus the square of the coefficients (the L2 penalty). Coefficients shrink toward zero — but rarely reach it. The model becomes simpler and smoother, and stops reacting wildly to small changes.

Best when correlated features make the model nervous and jittery.Think genomics, sensor arrays, anything with more columns than rows.

🧬 Use case — genetic analysis. With 10,000 genes predicting one trait, many genes are correlated. A standard model assigns massive positive/negative weights that cancel out. Ridge keeps all 10,000 genes but shrinks their impact so no single gene dominates artificially.

Wild vs. smooth
Ridge (solid) shrinks coefficients so the model stops chasing noise (dashed).

How to read this: the dashed line memorised every point and will fail on new data. The solid Ridge line trades a little training accuracy for a model that generalises.

Lasso (Least Absolute Shrinkage and Selection Operator) shrinks coefficients like Ridge, but with the L1 penalty it can push them all the way to zero.

That means Lasso performs feature selection: it looks at your data, decides which variables are useless, and deletes them from the equation. The final model is far easier to interpret — it only includes the factors that matter.

Best when you suspect most of your features are noise.Think sparse signals hidden in wide datasets.

🥗 Use case — nutritional science. Given 500 food items, most (water, lettuce, spices) have zero impact on weight gain. You want a model that says “Sugar” and “Fat” matter and ignores the rest — Lasso sets the coefficient for “Salt” to exactly zero.

Feature selection in action
0 0.2 0.4 0.6 0.8 Sugar 0.80 Fat 0.60 Fiber 0.20 Salt 0.00 Water 0.00 Lasso coefficients — useless features are shrunk to exactly zero.

How to read this: three ingredients keep a coefficient; two are deleted entirely. The model got smaller and more honest.

What if you have correlations (Ridge’s strength) and want to eliminate useless variables (Lasso’s strength)? Enter Elastic Net.

It combines L1 and L2 penalties, balancing Lasso’s aggressive feature elimination with Ridge’s stability. It is the safe bet when you have a messy, high-dimensional dataset and don’t know which regularisation to pick.

Best when features arrive in correlated groups and only some groups matter.Think financial forecasting with hundreds of economic indicators.

📊 Use case — financial forecasting. Economic indicators are highly correlated (inflation moves with interest rates) and some are pure noise. Elastic Net groups correlated variables together like Ridge, then selects or rejects the whole group like Lasso.

The middle ground
0 0.2 0.4 0.6 0.8 Sugar 0.65 0.8 0.78 Fat 0.5 0.6 0.58 Fiber 0.18 0.2 0.19 Salt 0.12 0 0 Elastic Net coefficients — groups correlated features like Ridge, deletes noise like Lasso.
Ridge (L2)Lasso (L1)Elastic Net

How to read this: Elastic Net tracks Lasso on the real signals and Ridge on the grouped ones — a pragmatic blend of the two penalties.

03Cheat sheet

The regression cheat sheet#

Pin this next to your keyboard. When a new dataset lands, match the shape of the problem to the row — then read the full section above.

TypeKey characteristicBest use case
LinearStraight-line relationshipSales forecasts, simple trends
PolynomialCurved line (exponents)Growth rates, biology
LogisticS-curve (probabilities)Classification (Yes/No)
RidgeShrinks coefficients (L2)Multicollinearity (correlated data)
LassoEliminates features (L1)Feature selection (sparse data)
Elastic NetHybrid (L1 + L2)Complex, high-dimensional data
04Choosing

How I would choose#

Start with the shape of the output, then the shape of the data. The simplest model that respects both usually wins — and regularization is not an admission of defeat, it is good hygiene.

Which regression fits your problem?

1
If the output is a number and the trend looks straight, start with Linear.

It is the fastest honest baseline, and its coefficients explain themselves.

2
If the output is Yes/No, switch to Logistic.

You get probabilities you can threshold, not impossible 500% answers.

3
If the scatter bends, add powers with Polynomial.

Underfitting a curve is as wrong as overfitting a line.

4
If features multiply and correlate, regularize.

Ridge to shrink, Lasso to delete, Elastic Net when you need both.

A realistic workflow: fit Linear first as the baseline, check the residuals for curves, move to Polynomial if the bend is real, and reach for Ridge/Lasso/Elastic Net the moment your columns outnumber your instincts.

05Grounding

Sources#

The methods on this page are not folklore — three of them descend from specific papers. The teaching charts are illustrative; the references are real.

  1. Where the name comes from. Adrien-Marie Legendre published the least-squares method in 1805; Francis Galton coined the term “regression” in 1886, studying how children’s heights regress toward the mean.
  2. Hoerl & Kennard (1970) — Ridge. “Ridge Regression: Biased Estimation for Nonorthogonal Problems,” Technometrics 12(1). The original L2 paper. DOI
  3. Tibshirani (1996) — Lasso. “Regression Shrinkage and Selection via the Lasso,” JRSS B 58(1). The original L1 paper. DOI
  4. Zou & Hastie (2005) — Elastic Net. “Regularization and Variable Selection via the Elastic Net,” JRSS B 67(2). DOI
  5. Further study. James, Witten, Hastie & Tibshirani, An Introduction to Statistical Learning (free PDF; chapters 3–6 cover this page), and the scikit-learn linear models guide for the working implementation.
A calmer guide to the mathematics of prediction — for builders who want intuition, not just formulas.
Part of Ali’s Data Science Series · Updated 6 August 2026. Teaching charts are illustrative, not benchmarks.
Ali Reza Rashidi
Ali Reza Rashidi
Ali Reza Rashidi, a Senior Data Scientist-Gen Al | Al Architect | MLOps with over ten years of experience, He is the author of three books that delve into the world of data and management.

Comments are closed.

error: Content is protected!