Challenge - 5 Problems
Naive Bayes Text Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
How does Naive Bayes handle word independence in text classification?
Naive Bayes assumes that words in a text are independent of each other when calculating probabilities. What does this assumption mean in simple terms?
Attempts:
2 left
💡 Hint
Think about how the model treats each word when calculating probabilities.
✗ Incorrect
Naive Bayes treats each word as if it appears independently from others, simplifying calculations by ignoring word order or combinations.
❓ Predict Output
intermediate2:00remaining
Output of Naive Bayes prediction probabilities
Given the following Python code using sklearn's MultinomialNB for text classification, what is the output of the prediction probabilities?
NLP
from sklearn.feature_extraction.text import CountVectorizer from sklearn.naive_bayes import MultinomialNB texts = ['I love apples', 'I hate bananas'] labels = [1, 0] vectorizer = CountVectorizer() X = vectorizer.fit_transform(texts) model = MultinomialNB() model.fit(X, labels) new_text = ['I love bananas'] X_new = vectorizer.transform(new_text) probs = model.predict_proba(X_new) print(probs)
Attempts:
2 left
💡 Hint
Look at how the model was trained and the new text features.
✗ Incorrect
The new text 'I love bananas' contains 'love' from class 1 and 'bananas' from class 0. Both classes have 'I', and with Laplace smoothing, the likelihoods balance exactly, giving equal probabilities [[0.5 0.5]].
❓ Model Choice
advanced1:30remaining
Choosing the best Naive Bayes variant for text with word counts
You have a dataset of text documents represented as word counts. Which Naive Bayes variant is most suitable for this data?
Attempts:
2 left
💡 Hint
Consider which variant models count data well.
✗ Incorrect
Multinomial Naive Bayes is designed for count data like word frequencies, making it ideal for text classification with word counts.
❓ Hyperparameter
advanced1:30remaining
Effect of smoothing parameter alpha in Naive Bayes
In Multinomial Naive Bayes, what is the effect of increasing the smoothing parameter alpha?
Attempts:
2 left
💡 Hint
Think about how smoothing helps with words not seen in training.
✗ Incorrect
Alpha adds a small positive value to word counts to avoid zero probabilities for unseen words during prediction.
❓ Metrics
expert2:00remaining
Interpreting Naive Bayes classification report metrics
A Naive Bayes text classifier reports the following metrics on test data: precision=0.8, recall=0.5, accuracy=0.7. What does this tell you about the model's performance?
Attempts:
2 left
💡 Hint
Recall measures how many actual positives are found, precision measures correctness of positive predictions.
✗ Incorrect
Precision 0.8 means most predicted positives are correct, but recall 0.5 means it misses half of the actual positives, so it is conservative in positive predictions.