Intuition The One Core Idea
Both kinds of model answer "what is this thing?" — but a discriminative model just draws a line between the answers, while a generative model learns to paint each answer from scratch. Everything on the parent page is built from one bridge, Bayes' theorem , which lets you swap between "how likely is this class given the picture?" and "how likely is this picture given the class?".
Before you can read a single equation on the parent note, you need to own every symbol in it. This page introduces them one at a time, from absolute zero, each anchored to a picture. Nothing here assumes you have seen probability notation before.
Definition The two things every model sees
X = the features : everything we measure about one example. For an email it is word counts; for an image it is pixel brightness values.
y = the label : the answer we want, like "spam" or "cat".
The picture. Think of one row of a spreadsheet. The many columns on the left are X (the clues). The single column on the right is y (the truth).
Why the topic needs it. The whole debate — generative vs discriminative — is about which direction of the arrow between X and y you choose to learn. So we must name both ends of that arrow first.
Intuition A subscript is just an address
When you see x 1 , x 2 , … , x n , the little number is an address : x 3 means "the 3rd feature". The letter n is just "however many features there are". No new maths — it is house numbering for a list.
P ( something ) is a number between 0 and 1 measuring how sure we are the something is true. 0 = impossible, 1 = certain, 0.5 = a coin flip.
The picture. Picture a bar that can only be filled between empty and full. P = 0.95 is a bar filled 95% of the way up.
Intuition Why not just say "yes" or "no"?
Because real clues are fuzzy. An email with the word "meeting" and the word "lottery" is not clearly spam or not-spam — it is leaning . Probability lets the model say "80% spam" instead of being forced into a wrong hard answer.
This is the single most important notation on the parent page, so we build it slowly.
Definition The bar means "given that"
P ( A ∣ B ) reads: "the probability of A , given that B is already known to be true." The bar ∣ splits the sentence into what we want (left) and what we already know (right).
The picture. Imagine a big rectangle = all emails. Shade the region "spam" and the region "contains the word lottery". P ( spam ∣ lottery ) ignores the whole rectangle and looks only inside the lottery region, then asks: what fraction of that slice is spam?
Common mistake The bar is NOT symmetric
Why it feels symmetric: both sides are just events.
The fix: P ( A ∣ B ) = P ( B ∣ A ) in general. "Given it rains, chance of clouds" (≈ 1 ) is very different from "given clouds, chance of rain" (much less). Confusing these two directions is exactly the mistake Bayes' theorem exists to correct — keep this picture in mind.
Why the topic needs it. The parent note's entire distinction is written with this bar:
Discriminative learns P ( y ∣ X ) — "given the clues, which answer?"
Generative learns P ( X ∣ y ) — "given the answer, which clues would we see?"
These are the two directions of the same bar .
The parent note names P ( X ∣ y ) , P ( y ) , P ( X ) , and P ( y ∣ X ) . Here is each, from zero.
Definition The four players
P ( y ) = prior : how common each answer is before seeing any clues. "How many emails are spam in general?"
P ( X ∣ y ) = likelihood : if the answer were y , how likely are these exact clues ? "If it's spam, would we see these words?"
P ( X ) = evidence : how likely these clues are at all , across every possible answer.
P ( y ∣ X ) = posterior : the thing we actually want — the answer after weighing the clues.
The picture. Three levers feed one dial. The prior and the likelihood are levers you learn from data ; the evidence is a normaliser; the posterior is the dial they move.
Prior = befor e clues. Poster ior = post (after) clues. The likelihood is the "evidence pull" that turns one into the other.
The parent note writes the evidence as P ( X ) = ∑ y ′ P ( X ∣ y ′ ) P ( y ′ ) . Two new symbols: ∑ and y ′ .
Definition The big Sigma is "add them all up"
∑ y ′ ( stuff ) means: take stuff , plug in every possible value of y ′ one at a time, and add all the results. The y ′ (read "y-prime") is a stand-in that walks through every class so we don't reuse the letter y .
The picture. If there are only two classes, spam and not-spam, then
∑ y ′ P ( X ∣ y ′ ) P ( y ′ ) = P ( X ∣ spam ) P ( spam ) + P ( X ∣ not ) P ( not ) .
Two terms, added. That's all ∑ did here.
Intuition Why sum — "marginalising"
The clues X had to come from some class . To find how likely X is overall, we consider every way it could have arisen and add those ways up. Summing over all values of a variable to "average it out" is called marginalising . It is why the posterior denominator is a sum.
Naive Bayes on the parent page uses P ( X ∣ y ) = ∏ j = 1 n P ( x j ∣ y ) .
Definition The big Pi is "multiply them all"
∏ j = 1 n ( stuff j ) means multiply stuff together for j = 1 , 2 , … , n . Same idea as ∑ but with × instead of + .
Intuition Why multiply, and when it is allowed
When two events don't affect each other (they are independent ), the chance of both is the product of each: P ( coin heads AND die six ) = 2 1 × 6 1 . Naive Bayes assumes each word/pixel is independent of the others given the class , so the joint likelihood becomes a product. This is the "naive" shortcut — usually wrong in detail but useful in practice.
Common mistake "Naive Bayes assumes features are independent."
Why it feels right: the product looks like plain independence.
The fix: it assumes independence given the class — P ( X ∣ y ) = ∏ j P ( x j ∣ y ) , not P ( X ) = ∏ j P ( x j ) . Details are on the parent note; the picture to hold is "independent inside each class bucket ."
These appear inside the parent's examples. You only need to recognise their shape .
e and the exponential
e ≈ 2.718 is a fixed number. e z grows fast for positive z and shrinks toward 0 for negative z , but never goes negative . That "always positive" property is why it is used to build probabilities.
Intuition Softmax = sigmoid for many classes
softmax ( z ) k = ∑ j e z j e z k takes several raw scores, makes them all positive with e ( ⋅ ) , then divides by their total so they sum to 1 . It is the many-answer version of the sigmoid.
Definition The Gaussian (bell curve)
N ( μ , σ 2 )
N ( μ , σ 2 ) is the familiar bell-shaped hump. μ ("mu") is the centre (where the peak sits) and σ 2 ("sigma-squared") is the spread (how wide the hump is). Generative models use it because pixel brightness is a continuous number, and a bell curve is the simplest way to say "values near the average are common, far ones are rare."
σ the sigmoid vs σ the spread
Why it confuses: the same Greek letter is reused.
The fix: σ ( z ) with a bracket after it = the S-curve function. σ 2 inside N = the width of a bell. Context (a bracket vs a square) tells them apart.
The parent note says "pick the class with highest P ( y = k ) P ( X ∣ y = k ) ."
arg max k ( score k ) means "return the label k that gives the biggest score", not the score itself. If digit "5" scores highest, argmax returns 5 .
Intuition Why we can drop the denominator
To rank classes we don't need the evidence P ( X ) — it is the same number for every class, so it never changes the winner. We say the posterior is proportional to the top of the fraction: P ( y ∣ X ) ∝ P ( X ∣ y ) P ( y ) . The symbol ∝ means "equal up to a constant we don't care about." This is why classification can skip computing P ( X ) .
Conditional probability with the bar
Probability P between 0 and 1
Bayes theorem four players
Generative learns P of X given y
Discriminative learns P of y given X
Exponential sigmoid softmax
Test yourself — cover the right side and answer out loud.
What does X stand for and what does y stand for? X = the measured features (clues); y = the label (the answer we want).
What does the bar in P ( A ∣ B ) mean? "Probability of A given that B is already known to be true."
Is P ( A ∣ B ) equal to P ( B ∣ A ) ? No — conditional probability is not symmetric; the direction matters.
Name the four Bayes quantities and which is the answer we want. Prior P ( y ) , likelihood P ( X ∣ y ) , evidence P ( X ) , posterior P ( y ∣ X ) — the posterior is the goal.
What does ∑ y ′ do and why is it in the evidence? It adds a term for every possible class ("marginalising"), because the data could come from any class.
What does ∏ j mean, and what assumption lets Naive Bayes use it? Multiply over all features; it needs features to be independent given the class .
Why use e ( ⋅ ) to build probabilities? Because e z is always positive, so ratios of exponentials stay in the valid [ 0 , 1 ] range.
What does σ ( z ) = 1 + e − z 1 do to a score? Squashes any real score into a probability between 0 and 1 along an S-curve.
In N ( μ , σ 2 ) , what are μ and σ 2 ? μ = centre of the bell; σ 2 = its spread/width.
Why can classification ignore P ( X ) ? It is the same for every class, so it never changes which class wins (P ( y ∣ X ) ∝ P ( X ∣ y ) P ( y ) ).