Complete the code to import the TfidfVectorizer from scikit-learn.
from sklearn.feature_extraction.text import [1]
The TfidfVectorizer is the correct class to import for computing TF-IDF features from text data.
Complete the code to create a TfidfVectorizer instance with English stop words removed.
vectorizer = TfidfVectorizer(stop_words=[1])Setting stop_words='english' tells the vectorizer to remove common English stop words.
Fix the error in the code to transform the documents into TF-IDF features.
tfidf_matrix = vectorizer.[1](documents)The fit_transform method fits the vectorizer to the data and transforms it in one step.
Fill both blanks to get the feature names and convert the TF-IDF matrix to a dense array.
feature_names = vectorizer.[1]() dense_matrix = tfidf_matrix.[2]()
get_feature_names_out() returns the list of feature names (words). toarray() converts the sparse matrix to a dense numpy array.
Fill all three blanks to create a TfidfVectorizer with max 1000 features, fit and transform documents, and get feature names.
vectorizer = TfidfVectorizer(max_features=[1]) tfidf_matrix = vectorizer.[2](documents) features = vectorizer.[3]()
Setting max_features=1000 limits the vocabulary size. Then fit_transform fits and transforms the documents. Finally, get_feature_names_out() retrieves the feature names.