The interview problem
Derive a two-feature naive Bayes decision and show how duplicated features distort confidence.
Original practice, not a reported company interview. Scenarios and numbers are illustrative. Interview date: not applicable. Sources retrieved October 1, 2026.
1. Scope and worked approach
Assume binary class Y and binary features, with conditional independence given Y as the model assumption. Posterior odds equal prior odds multiplied by feature likelihood ratios. Estimate probabilities with smoothing so an unseen feature does not create an accidental zero. Compute in log space for many features. Distinguish a useful classification boundary from calibrated probabilities.
2. Trace the design or derivation
Estimate class priors → estimate conditional likelihoods → sum log evidence → normalize
Smoothing strength is tied to the event model: a binary present/absent feature differs from a token-count model. Explicitly choose which is being modeled before estimating likelihoods. A document with repeated occurrences can contribute repeated evidence in a count model, while a binary feature records only presence.
3. Calculate the example
Prior odds are 1:1 and one feature has likelihood ratio 3. One observation gives posterior probability 3/4. Duplicating that same feature and falsely treating the copy as independent gives odds 9 and probability 9/10, without adding information.
4. Failure cases and trade-offs
Correlated words or duplicated sensors violate the factorization assumption. Removing obvious duplicates helps but does not establish independence. Naive Bayes is cheap and can classify well despite imperfect assumptions; discriminative models or calibration may improve probabilities at greater data/computation cost.
5. Validation, follow-ups and self-review
Test zero counts, duplicated columns and log-space equivalence on a small table. Follow-up: why can accuracy remain good while log loss worsens? Self-review: separate conditional from marginal independence and avoid counting one fact twice.
Sources and related practice
Technical reference: scikit-learn.org — Conditional independence factorization and probability limitations.
Source publication/update: Not established. Retrieved October 1, 2026. The workflow, calculations and review exercises are original; this reference is not evidence that a company asked this question.
Continue with Logistic regression, from score to decision; Reason about base rates and diagnostic evidence.
Continue your preparation
Choose a connected learning path or browse more ML fundamentals questions. Read our editorial method and attribution policy.