Notes

Class-Conditional Likelihood

When you use a classifier, you’re really asking: “Given what I’m seeing in this email (or patient record), which label makes that observation most plausible?” Class-conditional likelihood is the piece of the puzzle that answers the “most plausible under this class” part.

What it means

The class-conditional likelihood is the probability of the observed features x assuming a particular class y: P(x | y). It does not mean “probability of the class given the features” (that’s P(y | x), the posterior). In Naive Bayes, we combine this likelihood with a class prior using Bayes’ rule:

P(y | x) ∝ P(x | y) P(y)

The model predicts the class that makes the observed features most likely after weighting by how common the class is.

How Naive Bayes computes it

Naive Bayes makes a simplifying assumption: features are conditionally independent given the class. That turns one hard probability into a product of easier ones:

P(x | y) = ∏ P(x_i | y)
  • MultinomialNB (spam/word counts): learns P(word | class).
  • BernoulliNB (word present/absent): learns P(feature=1 | class).
  • GaussianNB (continuous features): models each feature with a normal distribution per class.

Why it matters in practice

In spam detection, a high P(words | spam) pushes the decision toward “spam” even before considering how frequent spam is (P(spam)). If likelihoods are poorly estimated (e.g., rare words never seen in training), the product can collapse to zero—so Naive Bayes uses smoothing (like Laplace smoothing; in scikit-learn this is alpha) to keep P(x | y) sensible and predictions stable.

Class-conditional likelihood is the probability (or probability density) of observing an input’s features given a particular class label, written as P(x | y). In Naive Bayes, it is typically factorized into per-feature terms (e.g., P(x | y)=∏ᵢ P(xᵢ | y)) and combined with the class prior to compute posteriors for classification. It matters because it encodes how each class generates data; mis-specifying it degrades predictions.

Think of a lost-and-found desk sorting items into bins: “keys,” “wallets,” “phones.” For each bin, the clerk asks: if this item really belongs in this bin, how likely is it to have these clues—metal teeth, a keyring, a certain weight?

That’s the idea of Class-Conditional Likelihood. It means: “Assuming the item is in a particular class (category), how probable are the features we’re seeing?” In a spam filter, it’s “If this email is spam, how likely is it to contain words like ‘free’ or ‘winner’?” Naive Bayes uses these likelihoods to decide which class best fits the evidence.