Conditional probability answers "given that B happened, how likely is A?" — it's the difference between an event's probability in general, and its probability once you already have some relevant information.
Formula
\(P(A \mid B)\) is read "probability of A given B." \(P(A \cap B)\) is the probability both A and B happen together. \(P(B)\) is the probability of B on its own — this formula effectively "zooms in" on only the cases where B is true, then asks what fraction of those also have A.
Visual Intuition
P(A|B) asks: of everything inside circle B, what fraction also falls inside circle A?
Numerical Example
Out of 100 emails: 30 contain the word "free" (event B), and of those, 24 are spam (event A∩B). Also, 40 emails total are spam.
Notice this (0.8) is very different from the overall \(P(\text{spam}) = 40/100 = 0.4\) — seeing the word "free" substantially raises the probability of spam. This gap between the conditional and unconditional probability is exactly the signal a classifier like Naive Bayes learns to exploit.
total_emails = 100
contains_free = 30
spam_and_free = 24
p_spam_given_free = spam_and_free / contains_free
print(p_spam_given_free) # 0.8
Independence — The Special Case Where Conditioning Changes Nothing
If knowing B happened doesn't change the probability of A at all, they're independent — this is the assumption Naive Bayes makes between features (hence "naive"), even though it's rarely exactly true in real data.
Common Mistakes
- Confusing \(P(A\mid B)\) with \(P(B\mid A)\) — these are generally different numbers (this is the same mix-up covered in Bayes' Theorem).
- Assuming conditioning always changes the probability — for genuinely independent events, it doesn't, by definition.
Interview Relevance
Q: "How is conditional probability different from joint probability?" Joint probability \(P(A \cap B)\) is the chance both happen out of all outcomes; conditional probability \(P(A\mid B)\) restricts the "universe" to only outcomes where B already happened, then asks what fraction of those also have A.
Practice Question
Out of 200 loan applicants, 50 have a credit score below 600, and of those, 30 defaulted. What is \(P(\text{default} \mid \text{credit score} < 600)\)?