1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Natural Language Processing in R

Connected

Exercise

Classification modeling example

You have previously prepared a set of Russian tweets for classification. Of the 20,000 tweets, you have filtered to tweets with an account_type of Left or Right, and selected the first 2000 tweets of each. You have already tokenized the tweets into words, removed stop words, and performed stemming. Furthermore, you converted word counts into a document-term matrix with TFIDF values for weights and saved this matrix as: left_right_matrix_small.

You will use this matrix to predict whether a tweet was generated from a left-leaning tweet bot, or a right-leaning tweet bot. The labels can be found in the vector, left_right_labels.

Instructions

100 XP
  • Set the random seed to 1111 for reproducibility.
  • Create training and test datasets. Use a 75% sample for the training data.
  • Run a random forest model on the training data, use left_right_labels for the response vector y.
  • Print the random forest results.