What is the time complexity of predicting a single sample with Naive Bayes?

Quick Overview

Asks for the time complexity of classifying one new sample with a trained Naive Bayes model. Tests whether you can derive the cost from the per-class scoring formula, say which quantities the cost depends on, and account for sparse inputs in Multinomial and Bernoulli variants.

What is the time complexity of predicting a single sample with Naive Bayes?

Role: Machine Learning Engineer

Category: Machine Learning

Difficulty: easy

Interview Round: Other

What is the time complexity of predicting a single sample with Naive Bayes? ```hint What the model keeps Think about what a trained Naive Bayes model stores after fitting, and whether it needs the training set at prediction time. ``` ### What a Strong Answer Covers - The per-class scoring formula and how many terms it adds up - Which quantities the prediction cost depends on, and which it does not - How sparse inputs change the cost for Multinomial and Bernoulli Naive Bayes - The per-feature cost for categorical, count and Gaussian features - A comparison with a lazy learner such as KNN ### Follow-up Questions - What is the time complexity of training Naive Bayes, and how does it compare with prediction? - If you need calibrated posterior probabilities instead of only the predicted class, what extra work is required and does it change the complexity? - How much memory does a trained Multinomial Naive Bayes model need for a vocabulary of $d$ words and $K$ classes? - How would prediction cost change if you relaxed the independence assumption, for example with a tree-augmented Naive Bayes?

Overview: Asks for the time complexity of classifying one new sample with a trained Naive Bayes model. Tests whether you can derive the cost from the per-class scoring formula, say which quantities the cost depends on, and account for sparse inputs in Multinomial and Bernoulli variants.

General logo
General
Nov 25, 2026
easyMachine Learning EngineerOtherMachine Learning
0
0

What is the time complexity of predicting a single sample with Naive Bayes?

What a Strong Answer Covers Guidance

  • The per-class scoring formula and how many terms it adds up
  • Which quantities the prediction cost depends on, and which it does not
  • How sparse inputs change the cost for Multinomial and Bernoulli Naive Bayes
  • The per-feature cost for categorical, count and Gaussian features
  • A comparison with a lazy learner such as KNN

Follow-up Questions Guidance

  • What is the time complexity of training Naive Bayes, and how does it compare with prediction?
  • If you need calibrated posterior probabilities instead of only the predicted class, what extra work is required and does it change the complexity?
  • How much memory does a trained Multinomial Naive Bayes model need for a vocabulary of dd words and KK classes?
  • How would prediction cost change if you relaxed the independence assumption, for example with a tree-augmented Naive Bayes?