Mental health disorders such as depression, anxiety, and post-traumatic stress disorder (PTSD) affect over one billion people worldwide, yet early detection remains a major clinical challenge. In recent years, text data from social media posts, clinical notes, and patient surveys has emerged as a rich source of signals for automated mental health screening. However, most existing machine learning models operate as black boxes, limiting clinical adoption. This paper presents an interpretable machine learning framework that combines natural language processing (NLP) feature extraction with explainable AI techniques — specifically SHAP (SHapley Additive exPlanations) and LIME (Local Interpretable Model-agnostic Explanations) — to predict mental health conditions from text while providing transparent, clinically meaningful explanations. A multi- class classification task involving depression, anxiety, PTSD, and healthy controls is performed on a dataset of 19,320 labelled text samples. The proposed XGBoost model with SHAP explanations achieves 87.3% accuracy and an AUC of 0.924, while the fine-tuned BERT model achieves 91.6% accuracy and an AUC of 0.961. Experimental results demonstrate that interpretability does not significantly compromise predictive performance, enabling trustworthy AI-assisted mental health screening.
Introduction
This study presents an interpretable Natural Language Processing (NLP) and Machine Learning (ML) framework for the early detection of mental health disorders from text data. Mental health conditions such as depression, anxiety, and PTSD affect millions of people worldwide, yet many remain undiagnosed due to limited access to healthcare, stigma, and the subjective nature of traditional clinical assessments. The increasing availability of digital text from social media, online forums, and electronic health records (EHRs) provides an opportunity to develop automated screening systems.
The proposed framework combines advanced NLP techniques with Explainable Artificial Intelligence (XAI) to achieve both accurate predictions and transparent decision-making. Unlike conventional deep learning models that operate as "black boxes," the system integrates SHAP (SHapley Additive Explanations) for global feature importance and LIME (Local Interpretable Model-agnostic Explanations) for instance-level explanations, enabling clinicians to understand why a prediction was made.
Main Contributions
The study contributes:
A comprehensive NLP preprocessing and feature extraction pipeline for mental health text.
A comparative evaluation of six machine learning models for four-class mental health classification.
Integration of SHAP and LIME to provide both global and local model explanations.
A clinically interpretable prediction framework suitable for mental health screening applications.
Related Work
Previous research showed that linguistic characteristics, such as increased use of first-person pronouns and negative emotion words, are indicators of depression. While deep learning models such as CNNs, LSTMs, and BERT have significantly improved detection accuracy, they often lack interpretability. Existing explainability studies primarily use SHAP, whereas this work combines SHAP and LIME to provide more comprehensive explanations for multi-class mental health classification.
System Architecture
The proposed framework consists of four stages:
Data collection from multiple text sources.
Text preprocessing and feature extraction.
Machine learning model training and prediction.
Explainability layer using SHAP and LIME, with clinician feedback enabling continuous model improvement.
Mathematical Framework
The study formulates:
TF-IDF for text representation.
XGBoost as the primary interpretable classification model with regularized loss.
SHAP for global feature contribution analysis.
LIME for local prediction explanations.
Standard evaluation metrics including Precision, Recall, F1-score, Macro F1, and AUC-ROC.
Dataset and Experimental Setup
The dataset contains 19,320 manually labeled text samples from:
Reddit mental health communities,
CLPsych 2015 shared task dataset,
De-identified clinical notes.
The four classification categories are:
Depression (5,420 samples)
Anxiety (4,870 samples)
PTSD (3,910 samples)
Healthy Control (5,120 samples)
Text preprocessing includes tokenization, lowercasing, URL removal, stop-word removal, and lemmatization. Four feature extraction methods are evaluated:
TF-IDF (unigrams and bigrams),
LIWC psycholinguistic features,
Word2Vec embeddings,
BERT contextual embeddings.
Results
Six machine learning models were evaluated using 5-fold stratified cross-validation. The results show:
Fine-tuned BERT achieved the best performance with 91.6% accuracy and an AUC of 0.961.
XGBoost was the strongest interpretable model, achieving 87.3% accuracy and an AUC of 0.924, outperforming Logistic Regression and Naïve Bayes.
SHAP and LIME successfully provided meaningful explanations by identifying the words and linguistic patterns influencing each prediction, improving transparency and supporting clinical decision-making.
Conclusion
This paper presented an interpretable machine learning framework for predicting mental health conditions from text data. By combining NLP feature extraction with SHAP and LIME explainability tools, the proposed system achieves strong classification performance (XGBoost: 87.3% accuracy, AUC 0.924; BERT: 91.6%, AUC 0.961) while providing transparent, clinically validated explanations. The framework bridges the gap between predictive performance and clinical trust, making it suitable for deployment as an AI-assisted mental health screening tool. Future work will extend the framework to multilingual datasets, multimodal inputs, and longitudinal mental health monitoring.
References
[1] S. Rude, E. Gortner, and J. Pennebaker, \"Language use of depressed and depression-vulnerable college students,\" Cognition and Emotion, vol. 18, no. 8, pp. 1121-1133, 2004.
[2] J. W. Pennebaker, R. J. Booth, and M. E. Francis, \"LIWC2007: Linguistic inquiry and word count,\" Austin, TX: LIWC.net, 2007.
[3] A. H. Orabi, P. Buddhitha, M. H. Orabi, and D. Inkpen, \"Deep learning for depression detection of Twitter users,\" in Proc. CLPsych, 2018, pp. 88-97.
[4] J. Devlin, M. Chang, K. Lee, and K. Toutanova, \"BERT: Pre-training of deep bidirectional transformers for language understanding,\" in Proc. NAACL, 2019, pp. 4171-4186.
[5] A. Yates, A. Cohan, and N. Goharian, \"Depression and self-harm risk assessment in online forums,\" in Proc. EMNLP, 2017, pp. 2968-2978.
[6] S. Ji, T. Zhang, L. Ansari, J. Fu, P. Tiwari, and E. Cambria, \"MentalBERT: Publicly available pretrained language models for mental healthcare,\" in Proc. LREC, 2022, pp. 7184-7190.
[7] S. M. Lundberg and S. Lee, \"A unified approach to interpreting model predictions,\" in Proc. NeurIPS, 2017, pp. 4765-4774.
[8] M. T. Ribeiro, S. Singh, and C. Guestrin, \"\'Why should I trust you?\': Explaining the predictions of any classifier,\" in Proc. KDD, 2016, pp. 1135-1144.