Session Ready
Exercise

Your first TfIdf

In this exercise, you will apply the TfIdf method to the small annak dataset, containing the first sentence of Anna Karenina by Leo Tolstoy.

Your task will be to work with this dataset and apply the TfidfVectorizer() function. Recall that performing a numeric transformation of text is your first step in being able to understand the sentiment of the text. The Tfidf vectorizer is another way to construct a vocabulary from our sentiment column.

Instructions
100 XP
  • Import the function for building a Tfdif vectorizer from sklearn.feature_extraction.text.
  • Call the TfidfVectorizer() function and fit it on the annak dataset .
  • Transform the vectorizer.