Mental Health Sentiment Analysis: Exploring an Optimized BERT with Deep Encodings
Received: 6 February 2025 | Revised: 19 February 2025 and 26 February 2025 | Accepted: 7 March 2025 | Online: 7 September 2025
Corresponding author: Abdul Rehman
Abstract
Deep learning technologies have significantly advanced the field of Natural Language Processing (NLP) in the recent past. A promising line of research in the existing study of text sentiment is the analysis of medical texts, which can potentially find numerous uses in medical diagnosis. However, sentiment analysis in the medical field remains challenging due to the complexity of medical language and context-aware interpretation of domain-specific ontologies. This paper focuses on the medical field and uses deep encoding techniques such as Fast-Text, Word2Vec, along with BERT and RoBERTa at the output layer for sentiment detection. The analysis specifically targets seven key mental health classes: Anxiety, Bipolar, Depression, Normal, Personality Disorder, Stress, and Suicidal. Text data were preprocessed using text cleaning, stop word elimination, and lemmatization to enhance the quality of the input data and improve the effectiveness of models. Experiments were carried out on a mental health dataset to analyze performance after the integration of deep encoding with diverse deep learning models. Based on the results, transformer-based models outperformed various other networks, achieving more than 95% accuracy. This study provides a basis for the selection of appropriate models in achieving accurate sentiment analysis within the medical field and is useful for research on designing efficient model frameworks.
Keywords:
sentiment analysis, medical text, deep learning, natural language processing, transformer modelsDownloads
References
M. Mahyoob, J. Algaraady, M. Alrahiali, and A. Alblwi, "Sentiment Analysis of Public Tweets Towards the Emergence of SARS-CoV-2 Omicron Variant: A Social Media Analytics Framework," Engineering, Technology & Applied Science Research, vol. 12, no. 3, pp. 8525–8531, Jun. 2022.
M. K. Myee, R. D. C. Rebekah, T. Deepa, G. D. Zion, and K. Lokesh, "Detection of Depression in Social Media Posts using Emotional Intensity Analysis," Engineering, Technology & Applied Science Research, vol. 14, no. 5, pp. 16207–16211, Oct. 2024.
Y. Abdelwahab, M. Kholief, and A. A. H. Sedky, "Justifying Arabic Text Sentiment Analysis Using Explainable AI (XAI): LASIK Surgeries Case Study," Information, vol. 13, no. 11, Nov. 2022, Art. no. 536.
J. K. Lin, T. W. Chien, Y. T. Yeh, S. Y. C. Ho, and W. Chou, "Using sentiment analysis to identify similarities and differences in research topics and medical subject headings (MeSH terms) between Medicine (Baltimore) and the Journal of the Formosan Medical Association (JFMA) in 2020: A bibliometric study," Medicine, vol. 101, no. 11, Mar. 2022, Art. no. e29029.
D. B. Fogel, "On the Growing Opportunity to Use Sentiment Analysis to Support Artificial Intelligence Applications in Healthcare," Psychology and Behavioral Science International Journal, vol. 10, no. 2, pp. 1–3, Jan. 2019.
T. Abbas et al., "IoMT-Based Healthcare Systems: A Review," Computer Systems Science and Engineering, vol. 48, no. 4, 2024.
R. Alharbey, J. I. Kim, A. Daud, M. Song, A. A. Alshdadi, and M. K. Hayat, "Indexing important drugs from medical literature," Scientometrics, vol. 127, no. 5, pp. 2661–2681, May 2022.
H. Huang, A. A. Zavareh, and M. B. Mustafa, "Sentiment Analysis in E-Commerce Platforms: A Review of Current Techniques and Future Directions," IEEE Access, vol. 11, pp. 90367–90382, 2023.
Z. Yang, D. Yang, C. Dyer, X. He, A. Smola, and E. Hovy, "Hierarchical Attention Networks for Document Classification," in Proceedings of the 2016 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, San Diego, CA, USA, 2016.
S. Xiong, H. Lv, W. Zhao, and D. Ji, "Towards Twitter sentiment classification by multi-level sentiment-enriched word embeddings," Neurocomputing, vol. 275, pp. 2459–2466, Jan. 2018.
J. Yu, J. Jiang, and R. Xia, "Global Inference for Aspect and Opinion Terms Co-Extraction Based on Multi-Task Neural Networks," IEEE/ACM Transactions on Audio, Speech, and Language Processing, vol. 27, no. 1, pp. 168–177, Jan. 2019.
Z. Yuan, S. Wu, F. Wu, J. Liu, and Y. Huang, "Domain attention model for multi-domain sentiment classification," Knowledge-Based Systems, vol. 155, pp. 1–10, Sep. 2018.
Y. Wang, M. Huang, X. Zhu, and L. Zhao, "Attention-based LSTM for Aspect-level Sentiment Classification," in Proceedings of the 2016 Conference on Empirical Methods in Natural Language Processing, Austin, TX, USA, 2016.
I. Masood, Y. Wang, A. Daud, N. R. Aljohani, and H. Dawood, "Towards Smart Healthcare: Patient Data Privacy and Security in Sensor‐Cloud Infrastructure," Wireless Communications and Mobile Computing, vol. 2018, no. 1, Jan. 2018.
P. Dumbach, L. Schwinn, T. Löhr, P. L. Do, and B. M. Eskofier, "Artificial intelligence trend analysis on healthcare podcasts using topic modeling and sentiment analysis: a data-driven approach," Evolutionary Intelligence, vol. 17, no. 4, pp. 2145–2166, Aug. 2024.
N. Ouerhani, A. Maalel, and H. Ben Ghézala, "SMAD: SMart assistant during and after a medical emergency case based on deep learning sentiment analysis: The pandemic COVID-19 case," Cluster Computing, vol. 25, no. 5, pp. 3671–3681, Oct. 2022.
H. Grissette and E. H. Nfaoui, "Deep associative learning approach for bio-medical sentiment analysis utilizing unsupervised representation from large-scale patients’ narratives," Personal and Ubiquitous Computing, vol. 27, no. 6, pp. 2055–2069, Dec. 2023.
M. C. Martinis, C. Zucco, and M. Cannataro, "An Italian lexicon-based sentiment analysis approach for medical applications," in Proceedings of the 13th ACM International Conference on Bioinformatics, Computational Biology and Health Informatics, Northbrook, IL, USA, Aug. 2022, pp. 1–4.
K. Denecke and Y. Deng, "Sentiment analysis in medical settings: New opportunities and challenges," Artificial Intelligence in Medicine, vol. 64, no. 1, pp. 17–27, May 2015.
D. C. Edara, L. P. Vanukuri, V. Sistla, and V. K. K. Kolli, "Sentiment analysis and text categorization of cancer medical records with LSTM," Journal of Ambient Intelligence and Humanized Computing, vol. 14, no. 5, pp. 5309–5325, May 2023.
Y. Zhao, L. Zhang, C. Zeng, W. Lu, Y. Chen, and T. Fan, "Construction of an aspect-level sentiment analysis model for online medical reviews," Information Processing & Management, vol. 60, no. 6, Nov. 2023, Art. no. 103513.
P. Kaur, A. K. Malhi, and H. S. Pannu, "Sentiment analysis of linguistic cues to assist medical image classification," Multimedia Tools and Applications, vol. 83, no. 10, pp. 30847–30866, Sep. 2023.
S. M. Jiménez-Zafra, M. T. Martín-Valdivia, M. D. Molina-González, and L. A. Ureña-López, "How do we talk about doctors and drugs? Sentiment analysis in forums expressing opinions for medical domain," Artificial Intelligence in Medicine, vol. 93, pp. 50–57, Jan. 2019.
S. Sarkar, "Sentiment Analysis for Mental Health." Kaggle, [Online]. Available: https://www.kaggle.com/datasets/suchintikasarkar/sentiment-analysis-for-mental-health.
Downloads
How to Cite
License
Copyright (c) 2025 Abdul Rehman, Muzamil Ahmed, Hikmat Ullah Khan, Amal Bukhari, Ali Daud, Hussain Dawood

This work is licensed under a Creative Commons Attribution 4.0 International License.
Authors who publish with this journal agree to the following terms:
- Authors retain the copyright and grant the journal the right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) after its publication in ETASR with an acknowledgement of its initial publication in this journal.