Machine Learning Based Sentiment Analysis For Text Messages
Machine Learning Based Sentiment Analysis For Text Messages
Abstract - People use online platforms such as Facebook, Twitter, etc. for social networking and share their opinions, feelings or beliefs
with others. Sharing is done by posts on these platforms. Sentiment analysis or opinion mining of these posts using machine learning
techniques is of great significance. The analysis is generally carried out with sentiment, subjectivity analysis or polarity calculations. In
this study, we performed a sentiment analysis of text messages using supervised machine learning techniques. They are mainly online
product reviews, general tweets in Tweeter and movie reviews. Messages are pre-processed and then used three different machine
learning techniques, namely Naïve Bayes, Decision Tree and Support Vector Machine (SVM) for sentiment analysis.
1. Introduction
follows; in Section 2, we discuss about related work in this
area. Section 3 is about the proposed system of our
103
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
Table 1. Summary of some of the attempts made by authors in sentiment analysis of text data
References
Data Techniques Approaches
(Year)
The effectiveness of applying Naïve Bayes and Support
[8] Naïve Bayes, Vector Machine are explored to classify sentiments based
IMDB dataset
(2002) SVM on the reviews made in movies.
Proposed a system based on SVM and Fuzzy domain
[9] Online hotel Fuzzy ontology ontology for opinion mining based on the collection of
(2016) reviews with SVM online reviews about hotels. The system computes the
polarity term of each feature.
104
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
3. Proposed System
The task of sentiment classification can usually be seen as For sentiment analysis on Twitter, varieties of benchmark
a two-class classification problem. This type of work datasets have been released over the last few years and are
mainly involves sentiment analysis as a text classification available online. We choose to select five different
problem, where feature selection has significant effect on datasets that have been widely used in Twitter sentiment
the performance of developed classifier models. analysis studies in literature. Table 2 provides a brief
overview of the datasets used in this paper.
105
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
106
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
(𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 ×𝑅𝑒𝑐𝑎𝑙𝑙)
Where, P(ai = wk | vj) is probability that word in position i 𝐹1 − 𝑆𝑐𝑜𝑟𝑒 = 2 × (𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛+𝑅𝑒𝑐𝑎𝑙𝑙) (6)
is wk, given vj .. One more assumption: P(ai = wk | vj) =
P(am =wk | vj) ∀ i, m.
Where, TP, FN, FP and TN refer respectively to the
number of true positive instances, the number of false
4.2. Support Vector Machine negative instances, the number of false positive instances
and the number of true negative instances. For sentiment
A Support Vector Machine (SVM) is a classifier that analysis on a tweet, high accuracy ensures that the
discriminates the data in numerous planes. For a given emotions of most messages in a dataset are evaluated and
supervised learning instance the SVM gives an optimal correctly predicted. The F1-score is a common metric for
hyper plane as output to categorize new data records. The both precision and recall. A receiver operating
SVM algorithms are implemented using a kernel. The characteristic (ROC) curve is a graphical plot that shows
kernel is responsible for translating input data to the the diagnostic capability of a binary classifier model as its
correct type. The SVM kernel takes input data of small discrimination threshold is varied. The ROC curve is
dimensions and transforms it into data space of higher developed by plotting the true positive rate (TPR) against
dimensions, thereby increasing data separability. This the false positive rate (FPR) at different threshold settings
strategy is called kernel tricks. We used the linear kernel Built classifier models are evaluated on the basis of
of the SVM, as it is mainly used to manage text data accuracy, macro-averaged F1-Scores of each model in five
because it includes many features and is usually linearly separate datasets (split as 70 percent training dataset and
separable. 30 percent testing dataset), and the ROC curves. The
results obtained are shown in Tables 3 and 4.
4.3. Decision Tree
Table 3. Classification accuracy (in %) of the models using the datasets
Decision Tree is a classification techniques in which the Dataset Naïve Bayes SVM ID3
divide-n-conquer process operates. The essential aspect of
IMDB 75.43 72.5 82.7
the decision tree is that it breaks down the complicated
decision-making process into a series of simpler decisions. Sentiment 140 73.18 75.5 81.94
In a tree where the root and the inner node are labeled with SemEval-2013 83.56 84.93 82.23
a query, and a leaf node is a prediction of an answer. We SemEval-2014 75.12 78.25 69.56
used an ID3 algorithm. It is a precursor to the C4.5
algorithm and is generally used in the area of machine STS-Gold 87.78 84.34 73.6
learning and natural language processing. For
classification of messages, information gain (see Equation Table 4. Macro-Averaged F1-Score of the classifier models using the
datasets
2) has been used as a split criterion.
Dataset Naïve Bayes SVM ID3
∆𝑦𝑖 IMDB 0.75 0.75 0.73
𝐺(𝑥, 𝑦) = 𝐻(𝑥) − ∑𝑖∈𝑣𝑎𝑙𝑢𝑒(𝑦) ∆𝑦 𝐻(𝑦𝑖 ) (2)
Sentiment 140 0.73 0.76 0.82
Where, H(x) is the entropy of the training set x with its SemEval-2013 0.85 0.862 0.72
attribute y. SemEval-2014 0.76 0.78 0.63
STS-Gold 0.862 0.827 0.682
5. Experimental Results
The plotted ROC curves of the three different classifier
The performance of sentiment classification can be models developed using the Sentiment 140 dataset are
evaluated by using the following metrics. shown (see Figures 2, 3, and 4). The reason for showing
(𝑇𝑃+𝑇𝑁)
the ROC curve only for Sentiment 140 dataset is because
𝐴𝑐𝑐𝑢𝑟𝑎𝑐𝑦 = (𝑇𝑃+𝑇𝑁+𝐹𝑃+𝐹𝑁) (3) of its large size which really helps in developing better
classifier models. Figures 2, 3, 4 reflect ROC curves of the
𝑇𝑃 Naïve Bayes classifier model, SVM and decision tree
𝑃𝑟𝑒𝑐𝑖𝑠𝑖𝑜𝑛 = (𝑇𝑃+𝐹𝑃) (4)
model using ID3 algorithm respectively.
𝑇𝑃
𝑅𝑒𝑐𝑎𝑙𝑙 = (5) The results shows a close competion between SVM and
(𝑇𝑃+𝐹𝑁)
ID3, as they are found to be better than Naïve Bayes
107
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
classifaction algorithm. However, Naïve Bayes performs Bayes and decision tree. We evaluated our models on the
better with the STS-Gold dataset. In case of SemEval- basis of metrics; classification accuracy, precision, recall,
2014, the best accuracy achieved is 78.25% which is quite F1-score, and ROC curve. After evaluating the developed
low. classifiers, we find that the results obtained from the
Decision Tree and SVM have a lower mean square error or
a higher accuracy with most of the datasets and are
considered to be good classifiers. We find our work to be
unique, as we have attempted in our study to provide an
overview of the various methods used in the sentiment
analysis of text data. We have also built and compared
three different classifiers using machine learning
techniques to five different datasets of varying sizes
and domains.
References
108
IJCAT - International Journal of Computing and Technology, Volume 7, Issue 6, June 2020
ISSN (Online) : 2348-6090
www.IJCAT.org
Impact Factor: 0.835
International Research Journal of Engineering and [15] K. Zvarevashe, O.O. Olugbara, A framework for
Technology, Vol 7(4), 2020. sentiment analysis with opinion mining of hotel reviews.
[7] Apurva Dixit, Alok Kumar Pal, Shraddha Temghare and In: conference on Information Communications
Vikas Mapari, Emotion Detection Using Decision Tree, Technology and Society (ICTAS), pp. 1–4, 2018.
International Journal of Advance Engineering and [16] V. Ramanathan, T. Meyyappan, Twitter text mining for
Research Development. 2017. sentiment analysis on people's feedback about Oman
[8] B. Pang, L. Lee, S. Vaithyanathan, Thumbs up?: tourism, In: 4th MEC International Conference on Big
sentiment classification using machine learning Data and Smart City (ICBDSC) IEEE. pp. 1--5, 2019.
techniques. In: Proceedings of the ACL-02 conference [17] Alec Go, Richa Bhayani and Lei Huang, Twitter
on empirical methods in natural language processing, Sentiment Classification using Distant Supervision
vol 10, pp. 79-86. 2002. Stanford University Stanford, CS224N project report,
[9] Farman Ali, Kyung-Sup Kwak and Yong-Gi Kim, Stanford, 2009
Opinion mining based on fuzzy domain ontology and [18] S. Rosenthal, Semeval 2014 task 9 description
Support Vector Machine: A proposal to automate online http://alt.qcri.org/semeval2014/ task9/
review classification, Applied Soft Computing, 2016. [19] H. Saif, M. Fernandez, Y. He, and H. Alani, Evaluation
[10] M.K. Dalal, M.A. Zaveri, Semi supervised learning datasets for twitter sentiment analysis: a survey and a
based opinion summarization and classification for new dataset, the sts-gold, In: Proceedings, 1st Workshop
online product reviews, Applied Computational on Emotion and Sentiment in Social and Expressive
Intelligence and Soft Computing, pp. 1–8, 2013. Media (ESSEM), Turin, Italy, 2013.
[11] Rui Xia, Feng Xu, ,Jianfei Yu et.al., Polarity shift
detection, elimination and ensemble: A three stage Authors -
model for document-level sentiment analysis,
Information Processing and Management, vol 52(1), pp. Abhishek Bhagat is currently pursuing his BTech (CSE) from the
36– 45, 2016. Department of CSE, School of Technology, Assam Don Bosco
[12] Efstratios Kontopoulo, Christos Berberidis, Theologos University. Currently, he is in his final year. His areas of interest
Dergiades , Nick Bassiliades, Ontology- based sentiment are Machine Learning, Big data analytics and Natural Language
analysis of twitter posts, Expert Systems with Processing.
Akash Sharma is currently pursuing his BTech (CSE) from the
Applications
Department of CSE, School of Technology, Assam Don Bosco
vol. 40, pp.4065-4074, 2013. University. He is a final year student at present. His areas of
[13] P. Kalaivani, K. L. Shunmuganathan, Sentiment interest are Machine Learning, Internet of Things (IoT) and Natural
classification of movie reviews by supervised machine Language Processing (NLP).
learning approaches, Indian Journal of Computer Sci.
Eng. Vol 4, pp.285–292, 2013. Dr. Sarat Kr. Chettri is an Assistant Professor in the Department
[14] T. Hassan, A. Soliman, M.A. Elmasry, A.R. Hedar, of Computer Applications, School of Technology, Assam Don
M.M. Doss, Utilizing Support Vector Machines in Bosco University. He has made several publications in
mining online customer reviews, In: Proceedings of international journals and conferences. His research area includes
22nd International Conference on Computer Theory and data science, machine learning and Internet of Things (IoT).
Applications (ICCTA), pp.192—196, 2012.
109