In this article, we’ll show you how to classify a tweet into either positive or negative, using two famous machine learning algorithms: Naive Bayes and N-Gram.

First, what is sentiment analysis?

Sentiment analysis is the automated process of analyzing text data and sorting it into sentiments positive, negative, or neutral. Using sentiment analysis tools to analyze opinions in Twitter data can help companies understand how people are talking about their brand.

Now that you know what sentiment analysis is, let’s start coding.

We have divided the whole program into three parts:

  • Importing the datasets
  • Preprocessing of datasets
  • Applying machine learning algorithms

Note: We have used Jupyter Notebook but you can use the editor of your choice.

Step 1: Importing the Datasets

Displaying the top ten columns of the dataset:


Image for post

From the dataset above we can clearly see the use of the following (none of which is of any use in determining the sentiment of a tweet):

  • Acronyms
  • Sequences of repeated characters
  • Emoticons
  • Spelling mistakes
  • Nouns

#machine-learning #sentiment-analysis #data-science #python #programming

Twitter Sentiment Analysis Using Naive Bayes and N-Gram
8.15 GEEK