What class does a Naive Bayes classifier predict if an input sample contains none of the vocabulary features?

Quick Overview

Work out which class a Naive Bayes text classifier predicts for an input that contains none of its vocabulary words. It tests whether you can write the likelihood for the Multinomial and Bernoulli variants, explain what drives the prediction when no words are present, and handle such inputs in practice.

What class does a Naive Bayes classifier predict if an input sample contains none of the vocabulary features?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

A Naive Bayes text classifier has been trained on a fixed vocabulary. At prediction time it receives an input sample that contains none of the vocabulary features. What class does it predict? ```hint Write out the likelihood Write the class-conditional likelihood for the variant you have in mind, then set every feature value to zero. ``` ```hint Variants disagree Multinomial and Bernoulli Naive Bayes treat an absent word differently. Check both. ``` ### What a Strong Answer Covers - The Multinomial case: what happens to the likelihood when every count is zero, and which class wins - How ties are broken when the priors are uniform - The Bernoulli case and why absent features still change the score - Why such predictions carry no information about the input, and how to handle them in a deployed system ### Follow-up Questions - How does the strength of Laplace smoothing change the Bernoulli Naive Bayes prediction for an empty input? - What does `predict_proba` return for such an input under Multinomial Naive Bayes, and why is it misleading to read it as confidence? - How would you detect empty or fully out-of-vocabulary inputs in production, and what would you return instead?

Overview: Work out which class a Naive Bayes text classifier predicts for an input that contains none of its vocabulary words. It tests whether you can write the likelihood for the Multinomial and Bernoulli variants, explain what drives the prediction when no words are present, and handle such inputs in practice.

General logo
General
Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

A Naive Bayes text classifier has been trained on a fixed vocabulary. At prediction time it receives an input sample that contains none of the vocabulary features. What class does it predict?

What a Strong Answer Covers Guidance

  • The Multinomial case: what happens to the likelihood when every count is zero, and which class wins
  • How ties are broken when the priors are uniform
  • The Bernoulli case and why absent features still change the score
  • Why such predictions carry no information about the input, and how to handle them in a deployed system

Follow-up Questions Guidance

  • How does the strength of Laplace smoothing change the Bernoulli Naive Bayes prediction for an empty input?
  • What does predict_proba return for such an input under Multinomial Naive Bayes, and why is it misleading to read it as confidence?
  • How would you detect empty or fully out-of-vocabulary inputs in production, and what would you return instead?