Sentiment Analysis Using Recurrent Neural Network
Sentiment Analysis Using Recurrent Neural Network
Abstract. This study aims to measure the accuracy of the sentiment analysis classification model
using deep learning and neural networks. This study used the algorithm Recurrent Neural
Network (RNN) and Word2vec. No previous research has used this model to analyze sentiments
written using Indonesian language so that the level of accuracy is unknown. The research began
by making a classification model of sentiment analysis. Then, the model was tested through
experiments. In this study, They used two classifications (positive and negative). Experiments
are carried out using training data sets and the test used data sets sourced from Traveloka
theybsite. The result shows that the model presents outstanding results and reaches about 91.9%.
Introduction
Currently, internet users in the world continue to experience rapid growth of technology. This increase
is one of the factors triggering the evolution of social media and e-commerce. This evolution has caused
an increase in the amount of information that is quite large or better known as big data. Today,
information is a very important source for determining decisions, such as information about product
reviews and ratings. Product reviews and ratings are very useful information for consumers to make
decisions. Therefore, current sentiment analysis is an interesting topic to study. Analysis sentiment is
one area of research in the field of NLP (Natural Language Processing) that classifies user reviews into
positive and negative reviews. Analysis sentiment is the study of user reviews of the products or entities
they use, such as food, hotels, airlines, etc [1], [2], [3]. The user's opinion on a product or entity has a
very high influence on one's decision making. [4] said that nearly 95 percent of customers saw previous
user reviews before they decided to buy or use products.
There are a lot of researches in the current field of analytical sentiment. Many algorithms are used in
research in the field of sentiment analysis, for example noble of algorithms using traditional machine
learning such as Support Vector Machine, Naïve Bayes, and learning using in-depth learning models
[5], [6]. Research using deep learning shows better results such as the classification of text, images,
sound and video. The working principle of deep learning using a neural network follows the architecture
of neural networks in the human brain. One of the neural network architectures used in analytic
sentiment is recurrent neural networks (RNN). RNN algorithm will associate each word in the input
with a certain time step. Simply put, the RNN will map the order of inputs into a vector of fixed size
[7]. Therefore, this study uses the RNN architecture to calculate word dependence in sentences on NLP.
Beside RNN, in this study also used word2vector to create word vectors.
This study evaluates and applies machine learning models using recurrent neural network algorithms
and word2vec. These models used a set of data to test them. The data set used was a data sets containing
reviews in Indonesian from the Traveloka theybsite. Existing models would be used to classify user
reviews into two categories, positive and negative reviews. The model would measure the level of
accuracy with a minimum threshold of 91.9 percent.
Content from this work may be used under the terms of the Creative Commons Attribution 3.0 licence. Any further distribution
of this work must maintain attribution to the author(s) and the title of the work, journal citation and DOI.
Published under licence by IOP Publishing Ltd 1
1st Bukittinggi International Conference on Education IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1471 (2020) 012018 doi:10.1088/1742-6596/1471/1/012018
Literature Review
The impact of the current internet development is that it is easy to get very large amounts of data. They
can use the data to be analyzed so as to produce useful information [8], [9]. Several studies on analytical
sentiment use traditional machine learning such as Support Vector Machine, Naïve Bayes etc. [1], [10],
[11] use several traditional machine learning algorithms such as SVM and Naive Bayes in their
researches to analyze sentiment from IMDB movie reviews.
Most of the previous studies use data sets in English and few use data sets in Bahasa Indonesian. [12],
[13], [14], [15] conduct sentiment analysis research using data sets in English, Chinese and Indian. [16]
use the RNN algorithm in their research to analyze sentiments in Malayalan language. The accuracy
produced from the study is 80% and can still be improved using deeper data sets. [17] analyzes the
performance of RNN and LSTM in classifying analytical sentiments for movie reviews. The results of
this study show an accuracy of 86.74%. From this study, They find that the model is susceptible to
overfitting.
[18] conduct research using CNN and word2vec to analyze sentiment on social media. They test
framework using public data sets in film review corpus and produce an accuracy of 45.4%. [19] in his
writing proposes an approach to analyze sentiments on product reviews using deep learning and
word2vec. The main idea in his research is the use of word2vec to learn word embedding and deep
learning to train product sentiment classes.
Methodology
The first steps in this research theyre scraping and scrawling the reviews on the Traveloka theybsite.
They use scraping and crawling techniques for data collection [20]. They process the review data into
word vectors and data sets. The data sets in this study is divided into two parts, first as a training data
sets and second testing data sets s. The flow of our research can be seen in figure 1.
Data Set
25% Testing
Polarity
Data Review Data Set Matrik RNN MODEL Testing
POS/NEG
2
1st Bukittinggi International Conference on Education IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1471 (2020) 012018 doi:10.1088/1742-6596/1471/1/012018
The next step is to make a representation of each word vector. They use a Tensorflow function to take
two arguments. The first argument is used to take the matrix from word2vec and the second argument
to retrieve the index of each word. Vector index is an index of rows for each word such as in table 2.
Table 2. Index Word
sentence Saya suka kamar luas dekat kolam renang bersih dan segar
word saya suka Kamar Luas Deket Kolam Renang Bersih Dan segar
index 56 260 72 291 138 48 49 88 3 1253
3
1st Bukittinggi International Conference on Education IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1471 (2020) 012018 doi:10.1088/1742-6596/1471/1/012018
Figure 4 is a visual form with histogram format from a data set review. From the histogram, the average
number of words is below 50. Then the max sequence value for our model is 50. The average number
of sentences in the model is used as the max sequence length
They create a set of matrices from the data sets above. RNN requires a collection of these matrices as
input. From the training process They get 5000 x 50 matrices. Table 4 shows the example of index vector
for a sentence. The data sets sets are then broken down by 75% for the training data sets and 25% for
the testing data sets.
Table 4. Data set matrix
Sentence
Staf sangat bagus, hotel nyaman seperti kita mengambil 3 kamar suite kerajaan dan rungan
besar dan memiliki ruang terpisah. Hotel ini bagus, sarapannya enak, Cuma jalanya kecil,
cukup untuk satu mobil. Semua baik baik saja
Index vector
403 44 185 37 828 146 154 1186 72 395
15900 3 478 329 3 802 491 37 39 185
212 33 45 2477 169 87 85 974 912 32
108 108 482 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Experiment RNN
They used some hyperparameters for creating RNN model in table 5. Hyperparameter is used to improve
the performance of the model.
Table 5. Hyperparameters
No Hyperparameter Total
1 Batch size 24
2 Number of clasess 2
3 Number of training iteration 10000
In this model, They use two placeholders. The first part is used for input into the RNN network while
the second part is used for labels. The second part, placeholder labels represent examples of positive and
negative training sets.
4
1st Bukittinggi International Conference on Education IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1471 (2020) 012018 doi:10.1088/1742-6596/1471/1/012018
Result
In the training process, first They accommodate a collection of related reviews and labels. By using the
run function, the network can define values where They can optimize components and minimize loss.
in addition, the run function is used to feed a collection of reviews and labels. This process will be
repeated as many as iterations have been set.
Figure 5 shows that pretrained model has accuracy approaching 92% percent and loss approaching 0
percent. As a comparison material in this study they also conducted a test using other algorithms such
as CNN, Naive Bayes, RNN conv. Accuracy results can be seen in table 6. These results show that RNN
with Word2vec can lead to better accuracy rate than the other model.
Table 6. Accuracy
Model accuracy
CNN + Word2vec 0.8923
Naïve Bayes 0.441
RNN Conv 0.8877
RNN + Word2vec 0.9198
Conclusion
In this research they have proposed model for sentiment analysis using RNN and word2vec. RNN in
this model is implemented using framework Tensorflow. The research results show that the model
approach has better accuracy with other machine learning models with result of accuracy is 91.98%.
From this research, They also have to pay attention to the possibility of overfitting the model when
carrying out the testing process. In the future They can try to use RNN and LSTM to overcome
overfitting problems and to improve the performance of the model.
Reference
[1] B. Pang, L. Lee, and S. Vaithyanathan, “Thumbs up? Sentiment Classification Using Machine
Learning Techniques,” in Proceedings of the ACL-02 conference on Empirical methods in
natural language processing - EMNLP ’02, 2002, vol. 10, pp. 79–86.
[2] A. Agarwal, B. Xie, I. Vovsha, O. Rambow, and R. J. Passonneau, “Sentiment Analysis of
Twitter Data,” in Proceedings of the Workshop on Language in Social Media (LSM 2011),
2011, pp. 30–38.
[3] F. Poecze, C. Ebster, and C. Strauss, “Social media metrics and sentiment analysis to evaluate
the effectiveness of social media posts,” Procedia Comput. Sci., vol. 130, pp. 660–666, 2018.
[4] C. Day, “The Importance of Sentiment Analysis in Social Media Analysis,” LinkedIn, 2015.
5
1st Bukittinggi International Conference on Education IOP Publishing
IOP Conf. Series: Journal of Physics: Conf. Series 1471 (2020) 012018 doi:10.1088/1742-6596/1471/1/012018