Exercise

Analyzing dimensionality and preprocessing

In this exercise, you have been provided with a lem_corpus which contains the pre-processed versions of the movie taglines from the previous exercise. In other words, the taglines have been lowercased and lemmatized, and stopwords have been removed.

Your job is to generate the bag of words representation bow_lem_matrix for these lemmatized taglines and compare its shape with that of bow_matrix obtained in the previous exercise. The first five lemmatized taglines in lem_corpus have been printed to the console for you to examine.

Instructions

100 XP
  • Import the CountVectorizer class from sklearn.
  • Instantiate a CountVectorizer object. Name it vectorizer.
  • Using fit_transform(), generate bow_lem_matrix for lem_corpus.