Log inStart free
LESSON 4.C2 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Generative vs discriminative

Watch Naive Bayes model each class while logistic regression learns only the boundary.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 4.C2 · CLASSIFIER BAY6 + 6 POINTS · BEST ERROR 14%
01
Stage 1 of 6 · Two classes
Each class of points comes from its own Gaussian cloud. The clouds overlap, so no boundary splits them perfectly.
Explain it simply

You see 6 dots with y = 1 and 6 squares with y = 0: the 12 points of 4.12 and 4.28. Each point has two features, x₁ across and x₂ up. The dashed ovals show the true clouds that make the points. They overlap, so even the best rule gets 14% of new points wrong.

A plot of 6 training points per class. The y = 0 squares sit lower left, the y = 1 dots upper right, and the clouds overlap. The best possible rule errs on 14% of new points.

training points: dot y = 1, square y = 0true cloudsfitted means, variances, weightschance of y = 1, boundaries, new pointsloss, extra error
training points · 6 per class · 2 featuresthe truth · two Gaussian cloudsx₁ →x₂ ↑789101112123456y = 0 □y = 1 ●y = 0 □ mean (-0.9, -0.6) · spread 1y = 1 ● mean (0.9, 0.6) · spread 1features independent · ρ = 0spreads equaltraining 6 + 6 points (drawn)error: the share of all new pointsthat land on the wrong sidebest rule: Bayes' rule, true cloudsits error 14% · no rule does betterx | y ~ N(μ_y, s_y² R) s = (1, 1) · ρ = 0training points · 6 per class · 2 featuresthe truth · two Gaussian cloudsx₁ →x₂ ↑789101112123456y = 0 □y = 1 ●y = 0 □ mean (-0.9, -0.6) · spread 1y = 1 ● mean (0.9, 0.6) · spread 1features independent · ρ = 0spreads equaltraining 6 + 6 points (drawn)error: the share of all new pointsthat land on the wrong sidebest rule: Bayes' rule, true cloudsits error 14% · no rule does betterx | y ~ N(μ_y, s_y² R) s = (1, 1) · ρ = 0
Toy: 2 Gaussian classes · 2 features · 6 to 64 points each (6 + 6: 4.12's 12 points)
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x∣y∼N(μy, Σy)\sy{x}{data}{x} \mid y \sim \mathcal{N}\big(\sy{mu}{ink}{\mu_y},\ \sy{S}{ink}{\Sigma_y}\big)
μ0=(−0.9,−0.6), μ1=(0.9,0.6), Σy=sy2[1001], s=(1,1)\mu_0 = (-0.9, -0.6),\ \mu_1 = (0.9, 0.6),\ \Sigma_y = s_y^2 \begin{bmatrix}1 & 0\\ 0 & 1\end{bmatrix},\ s = (1, 1)

Each class draws its points from its own Gaussian cloud.

Common mix-ups

MYTHMore training points let any model reach the best error.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01With correlated features, equal spreads and plenty of points, which model makes fewer errors?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.