Log inStart free
LESSON 4.28 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Naive Bayes

Watch Naive Bayes multiply one factor per feature, then pick the likelier class.


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.28 · BAYES BAYP(Y = 1) = 6/12 = 0.50
01
Stage 1 of 6 · Class prior
A Bayesian classifier starts from the prior P(y). Here 6 of 12 training points have y = 1.
Explain it simply

Each dot or square is a training point with two numbers, x₁ and x₂. The dots have the label y = 1. That's 6 of 12, so the prior for y = 1 is one half. The prior is your guess before you see a new point.

12 points on a plane: 6 dots with y = 1 and 6 squares with y = 0. The ledger shows the prior: 0.50 and 0.50.

training data, inputprior, fitted curve, factorposterior, chosen classwrong or zero county = 0, not spam, the added 1
12 training points · 2 features−2−2−1−1001122x₁x₂factor ledgery = 1y = 0prior P(y)0.500.5012 training points · 2 features−2−2−1−1001122x₁x₂factor ledgery = 1y = 0prior P(y)0.500.50
Toy: 12 points with 2 features (4.12's data) · or 6 messages over 5 words · 2 classes
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
P(y)=nyN\sy{prior}{param}{P(y)} = \frac{\sy{n}{data}{n_y}}{N}
P(y=1)=612=0.50P(y{=}1) = \frac{6}{12} = 0.50

The prior is the share of training examples in each class.

Common mix-ups

MYTHA word never seen in a class rules that class out.

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

Predict, then reveal
3 CHECKS · PRO
Q01Input B gets y = 0 at the learned prior. If P(y = 1) is 0.8, which class wins?

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.