How do you adjust Naive Bayes class priors when the training set does not reflect the real-world class distribution?

Quick Overview

Asks how to adjust Naive Bayes class priors when the training set's class mix differs from the real-world distribution. Tests understanding of label shift, Bayes' rule, correcting the outputs of an already trained model, and the limits of that fix.

How do you adjust Naive Bayes class priors when the training set does not reflect the real-world class distribution?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: medium

Interview Round: Other

How do you adjust Naive Bayes class priors when the training set does not reflect the real-world class distribution? For example, a fraud classifier may be trained on a balanced sample and then deployed where only a small fraction of transactions are fraud. ```hint Where the training mix enters Write the Naive Bayes posterior with Bayes' rule and check which factor depends on how the training set was sampled. ``` ```hint A model you cannot refit Think about how you would correct the outputs of a model that is already trained, and where the deployment class rates would come from if nobody gave them to you. ``` ### What a Strong Answer Covers - The assumption that makes replacing the priors valid, and why the class-conditional likelihoods can stay as they are - How to set the deployment priors when fitting the model - A post-hoc correction of the posteriors, including its log-space form and the renormalization step - Where the true priors come from when they are unknown - When prior correction is not enough, and how calibration affects it ### Follow-up Questions - How would you check whether the gap between training and deployment is label shift or a change in $P(x \mid c)$? - How does the EM procedure for estimating unknown deployment priors work, and when can it go wrong? - If you only care about ranking (for example ROC AUC), does the prior correction change anything? - How would you choose a decision threshold after correcting the priors?

Overview: Asks how to adjust Naive Bayes class priors when the training set's class mix differs from the real-world distribution. Tests understanding of label shift, Bayes' rule, correcting the outputs of an already trained model, and the limits of that fix.

Nov 24, 2026
mediumMachine Learning EngineerOtherMachine Learning
0
0

How do you adjust Naive Bayes class priors when the training set does not reflect the real-world class distribution?

For example, a fraud classifier may be trained on a balanced sample and then deployed where only a small fraction of transactions are fraud.

What a Strong Answer Covers Guidance

  • The assumption that makes replacing the priors valid, and why the class-conditional likelihoods can stay as they are
  • How to set the deployment priors when fitting the model
  • A post-hoc correction of the posteriors, including its log-space form and the renormalization step
  • Where the true priors come from when they are unknown
  • When prior correction is not enough, and how calibration affects it

Follow-up Questions Guidance

  • How would you check whether the gap between training and deployment is label shift or a change in P(x∣c)P(x \mid c) ?
  • How does the EM procedure for estimating unknown deployment priors work, and when can it go wrong?
  • If you only care about ranking (for example ROC AUC), does the prior correction change anything?
  • How would you choose a decision threshold after correcting the priors?