Exercise

Text classification using tf/idf vectors

Now that you've encoded the volunteer dataset's title column into tf/idf vectors, you'll use those vectors to predict the category_desc column.

Instructions

100 XP
  • Split the text_tfidf vector and y target variable into training and test sets, setting the stratify parameter equal to y, since the class distribution is uneven. Notice that we have to run the .toarray() method on the tf/idf vector, in order to get in it the proper format for scikit-learn.
  • Fit the X_train and y_train data to the Naive Bayes model, nb.
  • Print out the test set accuracy.