Complete the code to import the library used for text classification.
from sklearn.[1] import MultinomialNB
The MultinomialNB model is part of the naive_bayes module in scikit-learn, commonly used for text classification.
Complete the code to convert text documents into numbers for the model.
from sklearn.feature_extraction.text import {{BLANK_1 }} vectorizer = [1]()
CountVectorizer converts text into a matrix of token counts, which is a common first step in text classification.
Fix the error in the code to train the text classification model.
model = MultinomialNB()
model.[1](X_train, y_train)The fit method trains the model using the training data and labels.
Fill both blanks to create a dictionary of word counts for documents with words longer than 3 letters.
word_counts = {word: [1] for word in document.split() if len(word) [2] 3}This dictionary counts how many times each word appears if the word length is greater than 3.
Fill all three blanks to filter documents with label 'spam' and count words longer than 4 letters.
filtered = {doc: [1] for doc, label in dataset.items() if label == '[2]' and len(doc.split()[0]) [3] 4}This code filters documents labeled 'spam' and creates a dictionary with the document text in uppercase if the first word is longer than 4 letters.