Complete the code to create a CountVectorizer instance.
from sklearn.feature_extraction.text import [1] vectorizer = [1]()
The CountVectorizer converts text into a matrix of token counts.
Complete the code to transform text data into a count matrix.
texts = ['hello world', 'hello machine learning'] count_matrix = vectorizer.[1](texts)
fit_transform learns the vocabulary and returns the count matrix in one step.
Fix the error in the code to create a TF-IDF vectorizer.
from sklearn.feature_extraction.text import [1] tfidf_vectorizer = [1]()
TfidfVectorizer directly converts text to TF-IDF features.
Fill both blanks to create a dictionary of word counts for words longer than 3 letters.
words = ['data', 'science', 'is', 'fun'] word_counts = {word: [1] for word in words if len(word) [2] 3}
We assign count 1 for each word longer than 3 letters using len(word) > 3.
Fill all three blanks to create a TF-IDF matrix from text data.
from sklearn.feature_extraction.text import [1] texts = ['machine learning', 'deep learning', 'machine intelligence'] tfidf = [2]() matrix = tfidf.[3](texts)
Use TfidfVectorizer to create the vectorizer and call fit_transform to get the TF-IDF matrix.
