Sentiment Analysis Keeps Bad thought Away

By Akanksha Verma

GDSC, VIT Bhopal
GDSCVITBhopal
3 min readJul 12, 2022

--

Internet has given us the liberty to share our thoughts freely but do you think everyone is using this freedom in the right way. There is a lot of objectionable content flowing around in this open ocean. This is where Sentiment Analysers come into use. It does its work by bringing peace in its style by finding negative statements and removing them.

Contributing to such good motives of giving back to society, I tried coding out one myself.

Some General Thoughts about a Sentiment Analysis

Sentiment analysis can help brands monitor how their customers feel about them. They can analyze communities, forums, and social media platforms to keep an eye on their brand reputation. Or they can conduct surveys to understand what issues customers are facing.

Companies track their brand, product names and competitor mentions to build up an understanding of brand image over time. This helps companies assess how a new product launch would impact overall brand sentiment.

It can also help to analyze the negative influencing elements on the internet so that we can block such user handles to protect one’s reputation and keep that space of the internet free from cyberbullying.

Thinking over the same lines I thought of making one myself. This thought me various techniques for filtering out such negative content and eliminating it from the internet.

Code’s Working, Discussion

To get started with this project, at first we would be taking a data set in an excel sheet containing many sentences flagged with different emotions. And then we would load this dataset in jupyternotebook. Here the IDE would count the number of sentences flagged with different emotions just to check the counts of sentences of different emotions.

Next up would be the data cleaning process. In this, we would try to remove all the unnecessary characters or texts and generate the new dataset with cleaned-up texts. Such as removing user handles, numbers, emojis or any other data type which would hamper the data, making it complex to interpret.

Now we would perform logistic regression ML algorithm to train our model with respect to the considered dataset. The data would be divided into two parts: training part and testing part.

By doing this, we are ready to build our model by giving vectorizers and estimators. Going through the data fitting process we would check the accuracy of the model and check the output by taking any example as text. And at last, we would generate and save our newly created model.

Finally, we will create the front-end part of the project using streamlit and connect the model to that of a web app.

Modules Used in building of the project:

  • To analyze the given dataset, Pandas was used.
  • Streamlit was used in creating design and deploying the web application on localhost as interface for user for input and output
  • joblibto generates and saves the model
  • altairto displays and visualizes the generated chart according to input
  • seabornto plots the graph in jupyternotebook using countplot
  • sklearnto trains and generates the model by using Supervised learning –Logistic regression
  • neattext.functions had been used for cleaning dataset and generating a clean text version of the data set.

Results

Initially, the user inputs a single or multiline sentence. Then the model which we have trained, predicts emotions of the text concerning the available dataset. Also, it would display the amount of confidence or probability of several emotions like fear, joy disgust, etc. At last, to make the probability easier to understand, the code also portrays the values as pictorial representation: bar graph for several emotions. Now we can conclude different emotions and the number of emotions the text is carrying within it.

Conclusion of the build module

Sentiment analysis does opinion mining. It analyses people’s sentiments, attitudes, or emotions towards certain entities. This project tackles a fundamental problem of sentiment analysis, sentiment polarity categorization. It also helps to block or filter out some disrespectful words used over the internet to protect the mental health of each and every user on any platform where people are allowed to keep their opinions freely. Which would, in result, reduce cyberbullying.

Project Repository Link:

https://github.com/akayed-code/Sentiment-Analysis.git

--

--