PROBABILITY & STATISTICS · INTERVIEW QUESTION
Explain Bayes' theorem and give an ML application.
🟢 beginner · Probability Theory
Hint: P(A|B) = P(B|A)P(A)/P(B). Think about updating beliefs with evidence.
Answer
Bayes' theorem relates conditional probabilities, allowing us to update beliefs given new evidence.
In ML terms: posterior = likelihood × prior / evidence.
Applications in ML
- Naive Bayes classifier: directly applies Bayes' theorem for text classification
- Bayesian neural networks: place distributions over weights for uncertainty estimation
- Bayesian optimization: used for hyperparameter tuning
- Spam filtering: computes from word frequencies
python
from sklearn.naive_bayes import MultinomialNB
# Naive Bayes for text classification
clf = MultinomialNB()
clf.fit(X_train_tfidf, y_train)
y_pred = clf.predict(X_test_tfidf)The key insight is updating prior beliefs with observed data to get posterior beliefs — the foundation of Bayesian inference.
Related questions
- What is the Law of Large Numbers? How does it relate to ML?
- Explain the Central Limit Theorem and its assumptions. Why is it important in data science?
- What are conjugate priors? Give examples in Bayesian ML.
- Explain conditional probability and independence. How are they used in Naive Bayes?
- What is the difference between Type I and Type II errors? How do they relate to precision and recall?