What is the difference between Gaussian, Multinomial and Bernoulli Naive Bayes?
Gaussian NB assumes each feature is normally distributed within a class, so it suits continuous values. Multinomial NB models word counts. Bernoulli NB models binary present/absent features.
Explain it simply
All three use the same Bayes idea; they differ in how they model one feature's behaviour inside a class. Pick the version whose assumption matches the type of your feature.
Example
GaussianNB continuous numbers (height, income, sensor reading)
learns mean and variance per feature per class
MultinomialNB counts (how many times each word occurs)
or TF-IDF values
BernoulliNB binary flags (does the word appear at all? yes/no)
also penalises words that are absentExample email "free free offer" using a 3-word vocabulary [free, offer, meeting]:
Count vector (Multinomial) : [2, 1, 0]
Binary vector (Bernoulli) : [1, 1, 0]from sklearn.naive_bayes import GaussianNB, MultinomialNB, BernoulliNB
GaussianNB() # numeric columns
MultinomialNB() # CountVectorizer / TfidfVectorizer output
BernoulliNB() # CountVectorizer(binary=True) outputFor short texts such as SMS messages, Bernoulli or Multinomial are both common; try each with cross-validation. Gaussian NB on skewed data may do better after a log or power transform.
What to say in the interview
"Gaussian NB is for continuous features, Multinomial for counts or TF-IDF, Bernoulli for binary features. I choose by feature type and confirm with cross-validation."
Common mistakes
- Feeding negative values (such as standardised data) into MultinomialNB.
- Using GaussianNB on raw word counts.