Solution: Sentiment Analysis Using Naive Bayes
Let's see the implementation of a multinomial naive Bayes classifier that classifies the text as positive or negative.
We'll cover the following
Challenge
You are given the dataset.csv
file where reviews of several users along with their polarity are given. Implement a multinomial naive Bayes classifier which will classify the text as positive or negative.
At the end, you can test the correctness of your classifier by predicting if the sentence “This thing is simply awesome!” is positive or negative.
We have provided you with the code that reads the data set from a CSV file and splits it into a train set and test set.
Note: We don’t have any neutral reviews in our data set.
Solution
You can find the solution to the sentiment analysis problem below. You can play with the parameters test_size
and random_state
to improve the accuracy.
Get hands-on with 1200+ tech skills courses.