I took this example from the SKLearn website. Here's the initial code:
from sklearn.feature_extraction.text import CountVectorizer
corpus = ['This is the first document.',
'This document is the second document.',
'And this is the third one.',
'Is this the first document?']
# WORKING: assigning a variable "vectorizer" for CountVectorizer()
vectorizer = CountVectorizer()
X = vectorizer.fit_transform(corpus)
vectorizer.get_feature_names()
>>> ['and', 'document', 'first', 'is', 'one', 'second', 'the', 'third', 'this']
# NOT WORKING
X = CountVectorizer().fit_transform(corpus)
CountVectorizer().get_feature_names()
>>> NotFittedError: Vocabulary not fitted or provided
I'm confused at this point. Why do we have to assign a variable to CountVectorizer() if they are exactly the same thing?