Obtain tf-idf weights of words with sklearn

Viewed 6554

I have a set of texts of wikipedia.
Using tf-idf, I can define the weight of each word. Below is the code:

import pandas as pd                                             
from sklearn.feature_extraction.text import TfidfVectorizer

wiki = pd.read_csv('people_wiki.csv')

tfidf_vectorizer = TfidfVectorizer(max_features= 1000000)
tfidf = tfidf_vectorizer.fit_transform(wiki['text'])

The goal is to see the weights like shown in the tf-idf column:

enter image description here

The file 'people_wiki.csv' is here:

https://ufile.io/udg1y

1 Answers
Related