Deep Learning-Based Sentiment Analysis on Social Media Text Using Long Short-Term Memory (LSTM)
Keywords:
Sentiment Analysis, Deep Learning, LSTM, Social Media, Text PreprocessingAbstract
The large volume and informal nature of Indonesian social media text make manual sentiment analysis slow, inconsistent, and difficult to scale. This study evaluates a Long Short-Term Memory (LSTM) model for classifying public comments from X/Twitter into positive, neutral, and negative sentiment. A balanced dataset of 3,000 public Indonesian-language posts collected from January to March 2026 was manually labeled into three equal classes. Duplicate, irrelevant, advertising, and empty posts were removed; the remaining text underwent case folding, noise removal, tokenization, and padding. The data were stratified into 2,400 training and 600 testing instances. The model used a 10,000-word vocabulary, 100-token sequences, a 128-dimensional embedding, 128 LSTM units, dropout of 0.5, and a softmax output layer. On the held-out test set, the model obtained 87.00% accuracy, 86.80% precision, 86.50% recall, and 86.60% F1-score. Positive sentiment produced the strongest class-level performance, whereas neutral comments were more difficult because factual, ambiguous, and mixed expressions provide weaker affective cues. The findings show that LSTM provides a useful baseline for three-class Indonesian social media sentiment classification. However, generalization remains limited by the single-platform, topic-dependent dataset and the absence of repeated or cross-domain evaluation.
References
[1] S. Minaee et al., “Deep learning-based text classification: A comprehensive review,” ACM Comput. Surv., vol. 54, no. 3, pp. 1–40, 2021, doi: 10.1145/3439726.
[2] L. Zhang, S. Wang, and B. Liu, “Deep learning for sentiment analysis: A survey,” WIREs Data Min. Knowl. Discov., vol. 8, no. 4, Art. no. e1253, 2018, doi: 10.1002/widm.1253.
[3] E. Cambria, D. Das, S. Bandyopadhyay, and A. Feraco, Eds., A Practical Guide to Sentiment Analysis. Cham, Switzerland: Springer, 2017, doi: 10.1007/978-3-319-55394-8.
[4] S. Rosenthal, N. Farra, and P. Nakov, “SemEval-2017 Task 4: Sentiment analysis in Twitter,” in Proc. 11th Int. Workshop Semantic Evaluation, Vancouver, BC, Canada, 2017, pp. 502–518, doi: 10.18653/v1/S17-2088.
[5] S. Kowsari, K. J. Meimandi, M. Heidarysafa, S. Mendu, L. Barnes, and D. Brown, “Text classification algorithms: A survey,” Information, vol. 10, no. 4, Art. no. 150, 2019, doi: 10.3390/info10040150.
[6] B. Wilie et al., “IndoNLU: Benchmark and resources for evaluating Indonesian natural language understanding,” in Proc. 1st Conf. Asia-Pacific Chapter ACL and 10th Int. Joint Conf. Natural Language Processing, 2020, pp. 843–857.
[7] F. Koto, A. Rahimi, J. H. Lau, and T. Baldwin, “IndoLEM and IndoBERT: A benchmark dataset and pre-trained language model for Indonesian NLP,” in Proc. 28th Int. Conf. Computational Linguistics, 2020, pp. 757–770, doi: 10.18653/v1/2020.coling-main.66.
[8] F. Koto, J. H. Lau, and T. Baldwin, “IndoBERTweet: A pretrained language model for Indonesian Twitter with effective domain-specific vocabulary initialization,” in Proc. 2021 Conf. Empirical Methods in Natural Language Processing, 2021, pp. 10660–10668, doi: 10.18653/v1/2021.emnlp-main.833.
[9] G. I. Winata et al., “NusaX: Multilingual parallel sentiment dataset for 10 Indonesian local languages,” in Proc. 17th Conf. European Chapter ACL, 2023, pp. 815–834, doi: 10.18653/v1/2023.eacl-main.57.
[10] A. Chowanda and A. Chowanda, “Indonesian sentiment analysis model from social media by using ordinal deep learning,” in Proc. 2022 4th Int. Conf. Advanced Computer Science and Information Systems, 2022, pp. 54–59.
[11] J. Devlin, M.-W. Chang, K. Lee, and K. Toutanova, “BERT: Pre-training of deep bidirectional transformers for language understanding,” in Proc. 2019 Conf. North American Chapter ACL: Human Language Technologies, vol. 1, 2019, pp. 4171–4186, doi: 10.18653/v1/N19-1423.
[12] A. Vaswani et al., “Attention is all you need,” in Advances in Neural Information Processing Systems 30, 2017, pp. 5998–6008.
[13] D. Chicco and G. Jurman, “The advantages of the Matthews correlation coefficient over F1 score and accuracy in binary classification evaluation,” BMC Genomics, vol. 21, Art. no. 6, 2020, doi: 10.1186/s12864-019-6413-7.
[14] N. Reimers and I. Gurevych, “Sentence-BERT: Sentence embeddings using Siamese BERT-networks,” in Proc. 2019 Conf. Empirical Methods in Natural Language Processing and 9th Int. Joint Conf. Natural Language Processing, 2019, pp. 3982–3992, doi: 10.18653/v1/D19-1410.
[15] Z. Yang, Z. Dai, Y. Yang, J. Carbonell, R. Salakhutdinov, and Q. V. Le, “XLNet: Generalized autoregressive pretraining for language understanding,” in Advances in Neural Information Processing Systems 32, 2019, pp. 5753–5763.


