1. 学习
  2. /
  3. 课程
  4. /
  5. Feature Engineering for NLP in Python

Connected

练习

Comparing performance of n-gram models

You now know how to conduct sentiment analysis by converting text into various n-gram representations and feeding them to a classifier. In this exercise, we will conduct sentiment analysis for the same movie reviews from before using two n-gram models: unigrams and n-grams upto n equal to 3.

We will then compare the performance using three criteria: accuracy of the model on the test set, time taken to execute the program and the number of features created when generating the n-gram representation.

说明 1 / 共 2 个

undefined XP
  • 1

    Initialize a CountVectorizer object such that it generates unigrams.

  • 2

    Initialize a CountVectorizer object such that it generates ngrams upto n=3.