in cv.vocabulary_ if cv is an object of class CountVectorizer and cv =fit_transform(some_text) then if we call cv.vocabulary_ then we get a dictionary.prateek bhaiya says that this dictionary contains word-frequency mapping but in text ,frequencies of words not matches with the frequency given by dictionary.
What does cv.vocabulary_ gives
Hey there,
This does not give a mapping of word frequency with the word, rather it provides a dictionary with the mapping of the word index (in the list that is returned when a text is ‘transformed’ using the CountVectoriser object) with the word.
There must’ve been a confusion from your side.
‘fit_transform’ or simply ‘transform’ after fitting returns a list containing the frequency of every word in the vocabulary. And, ‘vocabulary’ returns the index of each word whose frequency has been mentioned above.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.