Analyzing Sentiments in Twitter Data with a Support Vector Machine
https://doi.org/10.46610/RRMLCC.2025.v04i01.001
Keywords:
Dataset, Deep learning (DL), Machine learning (ML), Sentiment analysis, Support vector machine, TweetsAbstract
Analyzing public sentiments through various tweets, particularly on platforms like Twitter, has emerged as a valuable tool for measuring opinions on multiple topics, including politics, elections, government policies, and known figures. These tweets convey a wide range of sentiments, from supportive to critical viewpoints. In this study, the tweets are categorized into negative, neutral, and positive sentiments, represented by -1, 0, and 1, respectively. We harnessed a support vector machine, a robust supervised machine learning technique recognized for its efficacy in sentiment analysis tasks. Proposed methodology encompassed stages, such as data collection and pre-processing, which involved tasks like text cleaning, tokenisation, and TF-IDF vectorization. Subsequently, we trained the SVM model and evaluated its performance visually using bar charts, confusion matrices, and a classification report, capturing key metrics such as accuracy, precision, recall, and F1-score. This study underscores the significance of social media-driven political sentiment analysis and its relevance in understanding public opinion and political discourse. Furthermore, the results underscore the efficiency of SVM in analyzing tweet sentiments, achieving an accuracy rate of 94%, a weighted average rate F1-score of 94%, and recall rates of 87% for negative sentiment, 97% for neutral sentiment, and 95% for positive sentiment. The proposed strategy achieves classification accuracy up to 94% on the standard datasets (i.e., Kaggle).
References
M. Ahmad, S. Aftab, M. S. Bashir, and N. Hameed, “Sentiment analysis using SVM: A systematic literature review,” International Journal of Advanced Computer Science and Applications, vol. 9, no. 2, 2018. [Online] Available: https://thesai.org/Publications/ViewPaper?Volume=9&Issue=2&Code=ijacsa&SerialNo=26.
A. Gupta, P. Tyagi, T. Choudhury, and M. Shamoon, “Sentiment analysis using support vector machine,” in 2019 International Conference on Contemporary Computing and Informatics (IC3I), pp. 49–53, 2019. [Online] Available: https://ieeexplore.ieee.org/abstract/document/9055645.
R. Obiedat et al., “Sentiment analysis of customers’ reviews using a hybrid evolutionary SVM-based approach in an imbalanced data distribution,” IEEE Access, vol. 10, pp. 22260–22273, 2022. [Online] Available: https://ieeexplore.ieee.org/document/9706209.
T. A. K. Suresh Kumar, A. S. Radha Mani, and A. J. Moshayedi, “Sentiment analysis of short texts using SVMs and VSMs-based multiclass semantic classification,” Applied Artificial Intelligence, vol. 38, no. 1, pp. 1–21, 2024. [Online]. Available: https://doi.org/10.1080/08839514.2024.2321555.
S. H. Imanuddin, K. Adi, and R. Gernowo, “Sentiment analysis on Satusehat application using support vector machine method,” JEEE Media Informatika, vol. 5, no. 3, pp. 143–149, 2023. [Online] Available: https://www.jeeemi.org/index.php/jeeemi/article/view/304.
Y. Al Amrani, M. Lazaar, and K. E. El Kadiri, “Random forest and support vector machine based hybrid approach to sentiment analysis,” Procedia Computer Science, vol. 127, pp. 511–520, 2018. [Online] Available: https://doi.org/10.1016/j.procs.2018.01.150.
H. Syahputra, “Sentiment analysis of community opinion on the online store in Indonesia on Twitter using support vector machine algorithm (SVM),” Journal of Physics: Conference Series, vol. 1819, no. 1, pp. 1–8, 2021. [Online] Available: https://iopscience.iop.org/article/10.1088/1742-6596/1819/1/012030/meta.
N. S. Reyna, C. Pruett, M. Morrison, J. Fowler, S. Pandey, and L. Hensleye, “Twitter: More than tweets for undergraduate student researchers,” J. Microbiol. Biol. Educ., vol. 23, no. 1, pp. 1–4, 2022. [Online] Available: https://doi.org/10.1128/jmbe.00326-21.
F. Meng and J. Wang, “Rating the crisis of online public opinion using a multi-level index system,” The International Arab Journal of Information Technology, vol. 19, no. 4, pp. 597–608, 2022. [Online]. Available: https://doi.org/10.48550/arXiv.2207.14740.
I. U. Khan et al., “A review of Urdu sentiment analysis with multilingual perspective: A case of Urdu and Roman Urdu language,” Computers, vol. 11, no. 1, 2022. [Online]. Available: https://doi.org/10.3390/computers11010003.
S. Hussein, “Twitter sentiments dataset,” Mendeley Data, V1, May 2021. [Online] Available: https://data.mendeley.com/datasets/z9zw7nt5h2/1.
D. A. Kristiyanti, D. A. Putri, E. Indrayuni, A. Nurhadi, and A. H. Umam, “Twitter sentiment analysis using support vector machine and deep learning model in e-learning implementation during the Covid-19 outbreak,” in AIP Conference Proceedings, vol. 2714, pp. 376–379, 2023. [Online] Available: https://doi.org/10.1063/5.0128685.
D. N. Fitriana and Y. Sibaroni, “Sentiment analysis on KAI Twitter post using multiclass support vector machine (SVM),” Jurnal RESTI (Rekayasa Sistem dan Teknologi Informasi), vol. 4, no. 5, pp. 846–853, 2020. [Online] Available: https://doi.org/10.29207/resti.v4i5.2231.
Naw and Naw, “Twitter sentiment analysis using support vector machine and K-NN classifiers,” International Journal of Scientific and Research Publications, vol. 8, no. 9, pp. 407–411, 2018. [Online] Available: https://www.ijsrp.org/research-paper-0918.php?rp=P827862.
M. Ahmad, S. Aftab, and I. Ali, “Sentiment analysis of tweets using SVM,” International Journal of Computer Applications, vol. 177, no. 5, pp. 25–29, 2017. [Online] Available: https://www.ijcaonline.org/archives/volume177/number5/28624-2017915758/.
S. Rani and J. Singh, “Sentiment analysis of tweets using support vector machine,” International Journal of Computer Science and Mobile Applications, vol. 5, no. 10, pp. 83–91, 2017. [Online] Available: https://www.ijcsma.com/abstract/sentiment-analysis-of-tweets-using-support-vector-machine-95823.html.
A. D’Andrea, F. Ferri, P. Grifoni, and T. Guzzo, “Approaches, tools and applications for sentiment analysis implementation,” International Journal of Computer Applications, vol. 125, no. 3, pp. 26–33, 2015. [Online] Available: https://www.ijcaonline.org/archives/volume125/number3/22414-2015905866/.
D. Bholane Savita and D. Gore, “Sentiment analysis on Twitter data using support vector machine,” International Journal of Computer Science Trends and Technology (IJCST), vol. 4, no. 3, pp. 365–370, 2016. [Online] Available: https://ieeexplore.ieee.org/abstract/document/8609670.
A. G. Shirbhate and S. N. Deshmukh, “Feature extraction for sentiment classification on Twitter data,” International Journal of Science and Research (IJSR), vol. 5, no. 2, pp. 2183–2189, 2016. [Online] Available: https://www.ijsr.net/getabstract.php?paperid=NOV161677.
R. Shyam and R. Chakraborty, “Machine learning and its dominant paradigms,” Journal of Advancements in Robotics, vol. 8, no. 2, pp. 1–10, 2021. [Online] Available: https://stmcomputers.stmjournals.com/index.php/JoARB/article/view/29.
V. Srivastava and R. Shyam, “Enhanced object detection with deep convolutional neural networks,” International Journal of All Research Education and Scientific Methods (IJARESM), vol. 9, no. 7, pp. 27–36, 2021. [Online] Available: https://www.ijaresm.com/enhanced-object-detection-with-deep-convolutional-neural-networks.
R. Shyam, “Convolutional neural network and its architectures,” Journal of Computer Technology & Applications, vol. 12, no. 2, pp. 6–14, 2021. [Online] Available: https://computerjournals.stmjournals.in/index.php/JoCTA/article/view/840.
R. Shyam and R. Singh, “A taxonomy of machine learning techniques,” Journal of Advancements in Robotics, vol. 8, no. 1, pp. 18–25, 2021. [Online] Available: https://stmcomputers.stmjournals.com/index.php/JoARB/article/view/144.
S. Singh, T. Jaiswal, R. Shyam, and S. Khanna, “Evaluation of tweet sentiments using NLP,” in International Symposium on Intelligent Informatics, S. M. Thampi, J. Mukhopadhyay, M. Paprzycki, and K.-C. Li, eds., (Singapore), pp. 225–238, Springer Nature Singapore, 2023. [Online] Available: https://link.springer.com/chapter/10.1007/978-981-19-8094-7_17.
R. Shyam, A. Mishra, A. Kumar, A. Chowdhary, and A. K. Srivastava, “Recording of class attendance using DL-based face recognition method,” in Data Science and Applications, S. J. Nanda, R. P. Yadav, A. H. Gandomi, and M. Saraswat, eds., (Singapore), pp. 249–260, Springer Nature Singapore, 2024. [Online] Available: https://link.springer.com/chapter/10.1007/978-981-99-7862-519.