In this tutorial, we are going to predict the sentiments of Amazon customers using Python. We apply a Logistic Regression machine learning algorithm to our data.
In this tutorial, we are going to predict the sentiments of Amazon customers using Python. We mainly use NumPy, pandas, seaborn, and scikit-learn(sklearn) libraries for this work. We apply a Logistic Regression machine learning algorithm to our data.
It calculates the top 20 positive and negative words. Also, it gives testing accuracy, confusion matrix, and model accuracy.
1) Dataset file of reviews with a .csv extension.
2) Install Jupyter Notebook or any similar working environment with the latest version of Python installed.
3) Python language.
4) Knowledge of Python libraries like NumPy, pandas, scikit-learn(sklearn), seaborn.
It contains the dataset of reviews(568454, 10).
Dataset link: Reviews.csv
1) Import the required Python libraries.
2) Reading the dataset. It contains a dataset of reviews. This dataset is present in the .csv extension file.
3) First, we add a new column of helpful% to our review dataset.
4) After that, cut the data into some slides and then analyze upvotes for different scores.
5) Next, we prepare a dataset containing scores and upvotes along with Id.
6) Create a pivot table for the dataset and plot a heatmap of this pivot table.
7) Now, start the calculation for prediction.
8) Remove reviews having a score value of 3, as it represents a neutral score.
9) Prepare ‘X’ and ‘y’ variables. ‘X’ represents our text data and ‘y’ represents the score.
10) To predict sentiments we apply logistic regression machine learning algorithms on data.
11)Apply Bag of words to the data. Calculate the test accuracy and print the top 20 positive and negative words.
12) Calculate the accuracy of the model along with the confusion matrix.