An Explainable Multi-Class Mental Health Classification Framework from Twitter Posts Using NLP and Machine Learning
DOI:
https://doi.org/10.33411/IJIST/1986Keywords:
Machine Learning, Explainable Artificial Intelligence (XAI), Natural Language Processing, Mental Health Classification, Twitter-Based Analysis, Multi-Class Detection, Clinical Interpretability, Linguistic Feature ExtractionAbstract
Social media and digital platforms have changed the landscape of mental health discourses, making platforms such as Twitter key for individuals to discuss their mental health and find solace. Although these platforms provide important linguistic insights for different mental health disorders, most current computational models focus on classification accuracy in detriment of model transparency. This "black box" makes it challenging to adopt this concept in the clinic where mental health professionals need explainable systems in order to be able to trust the computational results and validate automated decision-support systems. In this paper, we present an explainable NLP and machine learning-based multi-class mental health classification system to recognize and classify multiple mental health disorders from Twitter posts. Our proposed approach is based on n-gram TF-IDF vectorization coupled with classical machine learning models such as Support Vector Machine, Random Forest, Decision Tree, Logistic Regression, XGBoost and Naive Bayes, and combines classification with model explainability (SHAP/LIME) with the aim of uncovering linguistic patterns associated with specific mental health conditions. This framework aims to address this challenge by not only measuring predictive precision but also interpretability, paving the way for a scalable approach to identifying mental health concerns in digital environments early in their onset. The overall accuracy of the proposed Linear SVM model was 86.5%, macro precision 85.9%, macro recall 85.2%, and macro F1-score 85.5%. The framework also exhibited excellent class-wise performance with an accuracy of 94.0% for the Control (Neutral) class and 87.2% for the Depression class. The results indicate that the proposed explainable framework could accurately classify the posts on Twitter as belonging to any or all of the major mental health categories, and the classification could be interpreted clinically.
References
M. R. Meadi, T. Sillekens, S. Metselaar, A. van Balkom, J. Bernstein, and N. Batelaan, “Exploring the Ethical Challenges of Conversational AI in Mental Health Care: Scoping Review,” JMIR Ment Heal. 2025;12e60432 https//mental.jmir.org/2025/1/e60432, vol. 12, no. 1, p. e60432, Feb. 2025, doi: 10.2196/60432.
J. Jiang et al., “A review of transformer models in drug discovery and beyond,” J. Pharm. Anal., vol. 15, no. 6, p. 101081, Jun. 2025, doi: 10.1016/J.JPHA.2024.101081.
F. A. Wagay and Jahiruddin, “Classification of Mental Illnesses from Reddit Posts Using Sentence-BERT Embeddings and Neural Networks,” Procedia Comput. Sci., vol. 258, pp. 1669–1676, 2025, doi: 10.1016/J.PROCS.2025.04.398.
M. Malgaroli, T. D. Hull, J. M. Zech, and T. Althoff, “Natural language processing for mental health interventions: a systematic review and research framework,” Transl. Psychiatry, vol. 13, no. 1, p. 309, Dec. 2023, doi: 10.1038/S41398-023-02592-2.
K. Kalasampath, K. N. Spoorthi, S. Sajeev, S. S. Kuppa, K. Ajay, and A. Maruthamuthu, “A Literature Review on Applications of Explainable Artificial Intelligence (XAI),” IEEE Access, vol. 13, pp. 41111–41140, 2025, doi: 10.1109/ACCESS.2025.3546681.
Kamini Lamba, Shalli Rani, “Explainable machine learning for mental health prediction from social media behavior: a nested cross-validation study with SHAP and LIME interpretability,” Discov. Ment. Heal., vol. 6, no. 1, p. 25, 2026, doi: 10.1007/s44192-026-00373-z.
Y. Hu and M. Sokolova, “Explainable Multi-class Classification of the CAMH COVID-19 Mental Health Data,” May 2021, Accessed: Aug. 03, 2026. [Online]. Available: https://arxiv.org/pdf/2105.13430
S. and Han, R. and Mao, and E. Cambria, “Hierarchical Attention Network for Explainable Depression Detection on Twitter Aided by Metaphor Concept Mappings,” Int. Comm. Comput. Linguist., pp. 94–104, 2022, doi: 10.48550/arXiv.2209.07494.
E. Bao, A. Pérez, and J. Parapar, “Explainable depression symptom detection in social media,” Heal. Inf. Sci. Syst. 2024 121, vol. 12, no. 1, pp. 47-, Sep. 2024, doi: 10.1007/S13755-024-00303-9.
A. G. Bendebane L, Laboudi, Z. Saighi, A.; Al-Tarawneh, H.; Ouannas, “A Multi-Class Deep Learning Approach for Early Detection of Depressive and Anxiety Disorders Using Twitter Data,” Algorithms, vol. 16, no. 12, 2023, doi: 10.3390/a16120543.
Khalid Hasan, Jamil Saquer, Yifan Zhang, “Mental Multi-class Classification on Social Media: Benchmarking Transformer Architectures against LSTM Models,” 24th IEEE Int. Conf. Mach. Learn. Appl., 2025, [Online]. Available: https://arxiv.org/abs/2509.16542
O. Ovcharuk et al., “Detecting Mental Disorders in Social Media Using a Transformer-Based Ensemble of Binary Classifiers,” medRxiv, p. 2025.12.16.25342390, Dec. 2025, doi: 10.64898/2025.12.16.25342390.
L. Ilias and D. Askounis, “Multitask learning for recognizing stress and depression in social media,” Online Soc. Networks Media, vol. 37–38, p. 100270, Sep. 2023, doi: 10.1016/J.OSNEM.2023.100270.
M. O. Nusrat, W. Shahzad, and S. A. Jamal, “Multi Class Depression Detection Through Tweets using Artificial Intelligence,” vol. 1, Apr. 2024, doi:
https://doi.org/10.48550/arXiv.2404.13104
Muhammad Osama Nusrat, Waseem Shahzad, Saad Ahmed Jamal ., “Multi Class Depression Detection Through Tweets using Artificial Intelligence,” arXiv Prepr., 2024, doi: 10.48550/arXiv.2404.13104.
E. Rajabi and S. Kafaie, “Knowledge Graphs and Explainable AI in Healthcare,” Inf. 2022, Vol. 13, Page 459, vol. 13, no. 10, p. 459, Sep. 2022, doi: 10.3390/INFO13100459.
C. Callahan et al., “Real-World Use of a Mental Health AI Companion: Multiple Methods Study,” JMIR Form. Res., vol. 10, 2026, doi: 10.2196/86904.
B. Khan, M. Usman, and M. Binsawad, “A novel hybrid model for emotion detection in text through sequential and transformer-based approaches: LSTM enhanced RoBERTa (LER),” Sci. Reports 2025 161, vol. 16, no. 1, pp. 2224-, Jan. 2026, doi: 10.1038/s41598-025-31984-1.
A. N. Sutranggono, R. Sarno, and I. Ghozali, “Multi-Class Multi-Level Classification of Mental Health Disorders Based on Textual Data from Social Media,” J. Inf. Commun. Technol., vol. 23, no. 1, pp. 77–104, Jan. 2024, doi: 10.32890/JICT2024.23.1.4.
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2026 50sea

This work is licensed under a Creative Commons Attribution 4.0 International License.


















