Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
Long-term and short-term memory network based movie
comment sentiment analysis
Ruoxue Bi
Computer Science and Technology, Beijing Normal University - Hong Kong Baptist
University United International College, Zhuhai, 519000, China
[email protected]
Abstract. This paper proposes an emotional analysis method of movie reviews based on Long-
term and Short-term Memory(LSTM) Network model. Emotional analysis is widely used in
movie recommendation system, which can recommend and judge movies by understanding the
audience’s emotional response to movies. However, due to the characteristics of movie text and
the complexity of emotional expression, traditional methods such as machine learning have
limitations and shortcomings in emotional analysis. However, the LSTM model’s better memory
is utilized by the method proposed in this paper and the ability to capture the long-term
correlation in movie texts, which obviously improves the accuracy and reliability of emotional
analysis, and demonstrates the advantages of the LSTM model in emotional analysis compared
to the traditional model. Future research can further explore other deep learning models and
algorithms, so as to make emotional analysis more accurate and provide users with reliable movie
recommendation information.
Keywords: LSTM, word2vec, movie recommendation, emotional analysis.
1. Introduction
As a natural language processing technology, sentiment analysis can explore the emotional color of
subjective texts. It is widely used in many aspects. For the movie recommendation system, emotion
analysis can provide a more perfect movie recommendation algorithm by understanding the audience’s
emotional feedback to the movie. The traditional sentiment analysis method shows some disadvantages
and deficiencies in dealing with the semantic analysis of long texts and the change of sentiment polarity.
Deep learning has grown significantly in recent years, and approaches for sentiment analysis based on
deep learning have been introduced gradually. Among them, Long-term and Short-term Memory
Network (LSTM) can also be used in sentiment analysis because it can capture context information [1]
and deal with long-term dependence. Collaborative filtering algorithm is a kind of recommendation
algorithm that predicts users’ liking for unknown things by analyzing the similarity of users’ behaviors
[2]. The aim of this paper is to combine the LSTM emotion analysis model with the collaborative
filtering algorithm and apply it to the movie recommendation system to obtain more precise
recommendation results.
The collaborative filtering algorithm can be combined with the LSTM model, can refer to the
audience’s emotional feedback and the similarity of their love for movies at the same time, and on this
basis, in order to get more accurate and referential recommendation results. In a word, this paper adopts
© 2023 The Authors. This is an open access article distributed under the terms of the Creative Commons Attribution License 4.0
(https://creativecommons.org/licenses/by/4.0/).
150
Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
the LSTM emotional analysis model and collaborative filtering algorithm, and applies them to the movie
recommendation system. By analyzing the audience’s emotional feedback to the movie, then train a
large number of movie review data to get more personal and accurate movie recommendation results.
2. Literature review
Natural language processing and artificial intelligence technology have developed quickly in recent
years, movie sentiment analysis is also an important research direction. Applying sentiment analysis in
movie reviews can effectively analyze the audience’s preferences and provide more reference for market
research and movie recommendation. Researchers use the tagged movie review data to train the machine
model to complete the classification and prediction of emotional tags. More and more researchers are
incorporating the deep learning model into the task of emotion analysis as deep learning technology
develops, which has achieved better results in the field of emotion analysis, proved the superiority of
the deep learning model, and provided strong support for effectively analyzing the audience’s emotional
tendency and interest similarity.
2.1. Research status of deep learning based sentiment analysis
For the application research of introducing deep learning model as emotion analysis model in movies,
Socher et al. proposed recursive depth model in their paper [3], which can analyze the semantic
combination of emotion tree library. By combining the tree structure with the deep learning method then
achieved good results.
Kim et al. introduced convolutional neural network into the task of sentence classification, as shown
in the following article [4]. Researcher captured the local features of sentences through the convolution
layer, effectively realized the emotional classification of sentences, and applied this model to the
emotional analysis of movie reviews. Xu et al. put forward an long-term and short-term network model
based on attention mechanism [5], which is different from the previous judgment of emotional polarity
of the whole sentence, but classifies the different aspects stated in the sentence, and applies this model
to emotional analysis of film reviews, and obtains good results. Smith and others put forward a deep
neural network [6] which can handle multi-language and cross-cultural sentiment analysis tasks. By
extracting images from movie clips and mining audio features, it has been improved in feature extraction
and model optimization. Liang Jun and others applied recursive neural network to Weibo’s emotional
analysis [7], which avoided artificial feature design for specific tasks and saved a lot of manual work.
To sum up, convolutional neural networks and LSTM are two examples of deep learning models that
have been extensively used and researched for emotional analysis applications. The researchers have
continuously optimized the model framework and fully explored the features, and produced positive
results in the task of emotional analysis, which increased the reliability and accuracy of assessing the
emotional tendencies of film reviews and gave the film industry technological assistance for growth.
2.2. Research status of collaborative filtering algorithm
In recommendation systems, collaborative filtering algorithms are frequently employed, Movie
recommendation systems also frequently use it. Resnick and others discussed the architecture, function
and principle of GroupLens system [8], and pointed out the problems of sparse data and cold start in the
algorithm. GroupLens is a news recommendation system using collaborative filtering algorithm. Sarwar
et al. introduced the similarity and prediction calculation of collaborative filtering algorithm in detail
[9], and put forward a collaborative filtering algorithm based on items, and achieved better results. Kiren
and others put forward a combined model [10] in the paper, which integrates the domain-based
collaborative filtering model and the latent factor-based model. After testing on Netflix data, it is found
that the results are better than those on the previous data set. Bell and others put forward SVD++
algorithm in the paper [11], which expanded and assisted SVD model and improved the problems of
SVD’s difficulty in collecting implicit feedback data and sparse data.
151
Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
To sum up, collaborative filtering algorithm has been widely used in personalized recommendation
system, and it is still one of the research hotspots. The future research direction may pay more attention
to better solving the problems of data sparsity, improving recommendation effect and user experience.
3. Methodology
In this section, Internet Movie Database(IMDB) data set is used, and after data cleaning and other
preprocessing, feature extraction is performed.
3.1. Data preprocessing
The purpose of data processing is to remove invalid information and noise in data, such as HTML tags
and special symbols, which need to be deleted and replaced by regular expressions. After data cleaning,
data can be guaranteed to have higher accuracy and reliability in later modeling and analysis.
3.2. Feature extraction
After data cleaning, it is necessary to extract effective features from the data. Jieba word segmentation
tool is used to deal with word segmentation processing before extraction, and then word vectors are
extracted by combining Word2Vec [12] and COBW [13], and the word vectors are trained and predicted
by COBW, and finally effective features are extracted. CBOW mainly infers The current word is used
to determine the target vocabulary based on the context. The structure of CBOW model was shown in
Figure 1.
Figure 1. Schematic diagram of CBOW model structure
3.3. Emotional analysis model
The emotion analysis model proposed in this paper is long-term and short-term model, which is a deep
learning network controlled by forgetting gate, input gate and output gate. The initial step is to determine
the amount of information to keep from the cell state. By examining the input cells from the previous
moment and the current input vector, the forgetting gate determines whether the information in the cell
state needs to be saved or discarded by selectively forgetting the input cells at the previous moment. The
second stage involves selectively recording new information in the cell state, that is, the principle of
input gate is to judge the current cell state according to the current input quantity and the input cell at
the previous moment. Removing some old information and adding new information are realized in
updating the cell state. Finally, the output gate calculates the new cell state according to the current cell
state, the input cell at the previous moment and the current input vector, and finally obtains the output
of the current cell. In short, LSTM uses these three gates to control and calculate the state of storage
cells. Figure 2 is a schematic diagram of the cell structure of LSTM model.
152
Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
Figure 2. The LSTM unit structure is depicted in a schematic diagram
The back propagation algorithm for the LSTM model can be used to optimize the model parameters
in sentiment analysis. After the LSTM model completes the text classification, a fully connected layer
can be added, and the fully connected layer can map the cell state to the emotion category, and the
softmax classification function [14] can be used to classify and predict the emotion category. Finally,
the model is evaluated and debugged with training data and training sets marked with emotion categories.
3.4. Collaborative filtering algorithm
Movie recommendation is to recommend and screen similar products, the user-based collaborative
filtering algorithm will identify other users who are similar to the current ones and recommend movies
that these users like, but which haven’t been watched by the current users, movie recommendation
systems can also utilize it. The method of collaborative filtering algorithm [15] that is based on users
was proposed in this paper. By analyzing the common interests and behavior patterns of the audience,
the algorithm can discover the potential similarity and relevance between the audience, so as to provide
personalized and accurate services for the audience.
There are multiple methods for calculating similarity in the user-based collaborative filtering
algorithm, among which Pearson correlation coefficient and cosine similarity are the most commonly
used. Compared with them, Pearson correlation coefficient is suitable for measuring the linear
relationship between users, while cosine similarity is suitable for calculating the nonlinear relationship.
Cosine similarity algorithm makes the calculation more efficient and gives users a better experience.
The cosine similarity calculation formula is shown below.
∑i∈I Rui · Rvi
sim(u, v) = (1)
√∑i∈I R2ui √∑i∈I R2vi
After calculating the similarity, it is necessary to predict the target audience’s rating of movies that
have not been watched. This can be predicted according to the historical behavior of similar users, and
the weighted average is needed to calculate. The formula for predicting the rating is as follows.
∑𝑣∈𝑆(𝑢,𝐾) 𝑠𝑖𝑚(𝑢,𝑣)· 𝑅𝑣𝑗
𝑅𝑢𝑗 = (2)
∑𝑣∈𝑆(𝑢,𝐾) 𝑠𝑖𝑚(𝑢,𝑣)
In the prediction scoring formula, Ruj represents the prediction scores of audience u and project j, and
S(u, k) represents the selection of the K audiences with the highest similarity to the remaining target
audience u as a set. The selection based on a fixed threshold can be used to screen similar audiences to
improve the accuracy and reliability of recommendation results and prediction scoring. User-based
collaborative filtering algorithm still has the shortcomings of sparse data, and it is easy to ignore the
153
Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
multiple interests of the audience when calculating similar audience sets, which can be improved and
studied in related aspects in future work.
4. Experiment
4.1. Experimental environment
Table 1 depicts the experimental environment.
Table 1. Lab environment.
Experimental environment Experimental configuration
Operating system Ubuntu22.04
Programming language Python3.8.8
Deep learning framework Pytroch1.1.0
Graphics card model RTX309024GB
4.2. Data set
In this experiment, IMDB data set was selected, which contains a large number of users’ comments on
movies. Among them, there are 25,000 comments, including three fields: id, sentiment and review.
Among them, those with emotional classification of 1 are regarded as favorable comments, while those
with emotional classification of 0 are negative comments. Review represents the specific text content of
the comment. The data set divides training data and test data equally, and abandons neutral comments.
4.3. Result analysis
The test results assess the performance of the model proposed in this document by its accuracy, recall
and F1 value. The same data set is compared to SVM model, which is a the machine learning method.
Experimental findings show that the accuracy of the SVM detection is 83.2%, while the test accuracy
of the model selected in this paper is 87.2%, which has obviously improved the accuracy. After
analyzing the results, SVM needs to manually extract features in the task of sentiment analysis, and may
lose context information when extracting features and processing sequence data. The LSTM model is
capable of addressing the problem of long-term dependence and having a stronger memory capacity, so
it has more advantages than SVM model in emotional analysis tasks. This also shows the feasibility and
availability of the model chosen in this paper. The application of LSTM in the movie recommendation
system can help users get more accurate recommendation information, but the accuracy is still relatively
low. In the future research, researchers can further improve the accuracy and test efficiency by
introducing other deep learning or debugging loss functions.
5. Conclusion
In a word, this paper introduces LSTM model as an emotion analysis model through feature mining and
emotion analysis of users’ movie reviews, and combines it with user-based collaborative filtering
algorithm to calculate the emotion tendency and interest similarity of target users and similar users for
movies according to emotion tags, and provide users with more personalized and accurate movie
recommendations based on this. By comparing with traditional methods, it is proved that the traditional
machine learning method has improved the problem of low accuracy in emotion analysis tasks to some
extent. However, there are still many improvements in this method. Firstly, despite the LSTM model’s
advantages over the traditional model, it may have the problem of information loss when dealing with
long texts. Because of the limitation of the model structure, LSTM can not fully capture the details and
context in long texts, so the generalization ability of the sentiment analysis model can be improved by
improving the model structure or introducing more advanced deep learning models.
On the other hand, the movie recommendation system mainly recommends similar products, so the
user-based collaborative filtering algorithm can be applied and recommended. However, the algorithm
154
Proceedings of the 2023 International Conference on Machine Learning and Automation
DOI: 10.54254/2755-2721/36/20230437
has the shortcomings of sparse data and cultural differences and other factors will affect the emotional
analysis and expression of users. The user-based collaborative filtering algorithm will be slightly inferior
in considering different types of mixed recommendations, and how to improve the accuracy and quality
of mixed recommendations is also an important research direction. To sum up, the LSTM model still
has great application potential in emotion analysis in the future research. By improving the depth of
semantic features mining and optimizing the structure of deep learning model, using more advanced
hybrid recommendation algorithm can provide more accurate and efficient movie emotion analysis and
recommendation services.
References
[1] Tang, D.T, Qiu, S., & Yuan, X. (2015). Learning Sentiment-specific Word Embedding for Twitter
Sentiment Classification. Proceedings of the 24th International Conference on Artificial
Intelligence, pages 1351-1357.
[2] Koren, Y., Bell, R., and Volinsky, C. (2009). Matrix Factorization Techniques for Recommender
Systems. Computer, 42(8), 30-37.
[3] Socher, R., Perelygin, A., Wu, J. Y., Chuang, J., Manning, C. D., Ng, A., & Potts, C. (2013).
Recursive Deep Models for Semantic Compositionality Over a Sentiment Treebank. In
Proceedings of the 2013 conference on empirical methods in natural language processing (pp.
1631-1642).
[4] Kim, Y. (2014). “Convolutional Neural Networks for Sentence Classification.” In Proceedings of
the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), 1746-
1751.
[5] Xu, L., Bing, L., Le, Y., & Zhang, P. (2015). “Attention-based LSTM for Aspect-level Sentiment
Classification.” In Proceedings of the 2015 Conference on Empirical Methods in Natural
Language Processing (EMNLP), 606-615.
[6] Smith, John. “Affective Analysis of Movies using Deep Learning Techniques.” Journal of Film
Studies, vol. 14, no. 3, 2022, pp. 45-67.
[7] Liang Jun, Chai Yumei, Yuan Huibin, etc. Weibo’s emotional analysis based on deep learning [J].
journal of chinese information, 2014,28(05):155-161.
[8] Resnick, P., Iacovou, N., Suchak, M., Bergstrom, P., & Riedl, J. (1994). Grouplens: An open
architecture for collaborative filtering of netnews. In Proceedings of the 1994 ACM conference
on Computer-supported cooperative work (pp. 175-186). ACM.
[9] Sarwar, B., Karypis, G., Konstan, J., & Riedl, J. (2001). Item-based collaborative filtering
recommendation algorithms. In Proceedings of the 10th International Conference on World
Wide Web (pp. 285-295).
[10] Koren, Y. (2008). Factorization meets the neighborhood: a multifaceted collaborative filtering
model. In Proceedings of the 14th ACM SIGKDD international conference on Knowledge
discovery and data mining (pp. 426-434).
[11] Koren, Y., Bell, R., & Volinsky, C. (2009). Matrix factorization techniques for recommender
systems. Computer, 42(8), 30-37.
[12] Mikolov, T., Sutskever, I., Chen, K., Corrado, G., & Dean, J. (2013). Distributed representations
of words and phrases and their compositionality. Advances in neural information processing
systems, 26, 3111-3119.
[13] Mikolov, T., Chen, K., Corrado, G., & Dean, J. (2013). Efficient estimation of word
representations in vector space. arXiv preprint arXiv:1301.3781.
[14] Bridle, J. S. (199). Probabilistic interpretation of feedforward classification network outputs, with
relationships to statistical pattern recognition. Neurocomputing, 2(3), 227-236.
[15] Resnick, P., & Varian, H. R. (1997). Recommender systems. Communications of the ACM, 40(3),
56-58.
155