Social media platforms serve as a rich source of data for monitoring mental health, providing timely insights for early detection of depression through automated analysis of user-generated content. Utilizing the Mental Health Social Media dataset from Kaggle, this study investigates the effectiveness of deep learning models in classifying depression-related text. The data undergo comprehensive preprocessing, including normalization, HTML and URL removal, tokenization, and label encoding, followed by embedding and vectorization techniques such as BERT embeddings, Keras Tokenizer, and TF-IDF vectorization to capture semantic and contextual information. Data balancing methods, including SMOTE and random oversampling, are applied to address class imbalance. Multiple architectures, including BERT-based LSTM, BERT-BiLSTM, BERT-LSTM-GRU hybrids, standalone LSTM and GRU networks, and traditional machine learning classifiers such as Random Forest, SVM, and Voting Classifier are evaluated. Experimental results demonstrate that the Voting Classifier achieves the highest performance with an accuracy of 93.9%, F1-score of 93.7%, and ROC-AUC of 87.5%, outperforming individual deep learning and classical models. The analysis confirms that combining multiple models through ensemble learning significantly enhances the detection capability, providing a robust framework for accurate and context-aware depression classification from social media text, which can support timely mental health interventions and monitoring at scale.
Introduction
The text presents a study on automated depression detection from social media text using machine learning and deep learning techniques.
It explains that depression is a major global mental health concern, and social media platforms generate large amounts of user text that can reflect emotional states. To address limitations of traditional clinical and questionnaire-based methods, the study proposes an AI-based system that analyzes social media posts to detect depressive tendencies early.
The methodology involves collecting a large Twitter dataset labeled as “depression” and “no depression,” followed by extensive preprocessing (cleaning, tokenization, normalization), feature extraction using TF-IDF, BERT embeddings, and tokenizers, and handling class imbalance using SMOTE. The data is then split into training and testing sets.
Multiple models are developed and compared, including deep learning approaches (LSTM, GRU, BERT-LSTM, BERT-BiLSTM, hybrid architectures) and classical machine learning models (SVM, Random Forest). Ensemble methods like voting classifiers are also used. Advanced techniques such as explainable AI (LIME, SHAP) are included to improve interpretability, and a Flask-based system enables real-time prediction.
Conclusion
Social media text data provides a valuable resource for monitoring mental health conditions, particularly depression, by enabling timely and automated analysis of user-generated content. The study demonstrates that deep learning architectures, combined with effective preprocessing, embedding, and data balancing techniques, can significantly enhance classification accuracy. Techniques such as BERT embeddings, TF-IDF vectorization, and Keras Tokenizer enabled the models to capture contextual and semantic nuances in text, while SMOTE and random oversampling addressed class imbalance effectively. Various models, including BERT-LSTM, BERT-BiLSTM, BERT-LSTM-GRU, standalone LSTM and GRU networks, as well as classical classifiers such as Random Forest and SVM, were evaluated to determine their effectiveness. Among all evaluated methods, the Voting Classifier exhibited superior performance, achieving an accuracy of 93.9%, F1-score of 93.7%, and ROC-AUC of 87.5%, highlighting the advantages of ensemble learning in leveraging complementary strengths of multiple algorithms. The results indicate that integrating deep learning with ensemble techniques provides a robust and context-aware approach for depression detection in social media text. These outcomes emphasize the potential of automated systems to support early identification of mental health issues, offering scalable solutions for intervention and continuous monitoring, ultimately contributing to improved mental health awareness and timely support.
Future research can focus on expanding the dataset to include multilingual and cross-platform social media content, enhancing the generalizability of depression detection models. Incorporating multimodal data, such as images, videos, and user interaction patterns, can improve context understanding and detection accuracy. Advanced transformer-based architectures, including hybrid ensembles of BERT variants and graph neural networks, may capture complex semantic relationships more effectively. Real-time detection pipelines can be developed for continuous monitoring and early intervention. Further exploration of attention mechanisms and explainable AI techniques, such as Grad-CAM and SHAP, can provide insights into model decisions and increase transparency. Additionally, integrating longitudinal analysis to track behavioral patterns over time could enhance predictive capabilities and support proactive mental health support strategies.
References
[1] Chiong, R., Budhi, G. S., Dhakal, S., & Chiong, F. (2021). A textual-based featuring approach for depression detection using machine learning classifiers and social media texts. Computers in Biology and Medicine, 135, 104499.
[2] Hasib, K. M., Islam, M. R., Sakib, S., Akbar, M. A., Razzak, I., & Alam, M. S. (2023). Depression detection from social networks data based on machine learning and deep learning techniques: An interrogative survey. IEEE Transactions on Computational Social Systems, 10(4), 1568-1586.
[3] Benrouba, F., & Boudour, R. (2023). Emotional sentiment analysis of social media content for mental health safety. Social Network Analysis and Mining, 13(1), 17.
[4] Villa-Pérez, M. E., Trejo, L. A., Moin, M. B., & Stroulia, E. (2023). Extracting mental health indicators from english and spanish social media: A machine learning approach. IEEE Access, 11, 128135-128152.
[5] Kaushik, P., & Sharma, P. (2024, December). Integrating Machine Learning and Sentiment Analysis: A Comparative Study on Mental Health Classification from Social Media Data. In 2024 International Conference on Decision Aid Sciences and Applications (DASA) (pp. 1-6). IEEE.
[6] J. Liu, Y. Liu, W. Ma, Y. Tong, and J. Zheng, ‘‘Temporal and spatial trend analysis of all-cause depression burden based on global burden of disease (GBD) 2019 study,’’ Sci. Rep., vol. 14, no. 1, p. 12346, May 2024.
[7] Y. Meng, H. Li, J. Wang, Y. Xu, and B. Wang, ‘‘Cognitive behavioral ther apy for patients with mild to moderate depression: Treatment effects and neural mechanisms,’’ J. Psychiatric Res., vol. 136, pp. 288–295,Apr.2021, doi: 10.1016/j.jpsychires.2021.02.001.
[8] M. J. Samidoss and V. A. Doss, ‘‘Depression: An overview in the patho physiology and treatment,’’ Tech. Rep., 2021.
[9] L. Dobrek and K. G?owacka, ‘‘Depression and its phytopharmacotherapy—A narrative review,’’ Int. J. Mol. Sci., vol. 24, no. 5, p. 4772, Mar. 2023, doi: 10.3390/ijms24054772.
[10] J. P. Thekkekara, S. Yongchareon, and V. Liesaputra, ‘‘An attention-based CNN-BiLSTM model for depression detection on social media text,’’ Exp. Syst. Appl., vol. 249, Sep. 2024, Art. no. 123834.
[11] D. Dutta and A. D. Muni, ‘‘Artificial intelligence for mental health: A review based analysis of early detection and management of depression in elderly citizens,’’ Library Progress-Library Sci., Inf. Technol. Comput., vol. 44, no. 3, 2024.
[12] A. Amanat, M. Rizwan, A. R. Javed, M. Abdelhaq, R. Alsaqour, S. Pandya, and M.Uddin,‘‘Deep learning for depression detection from textual data,’’ Electronics, vol. 11, no. 5, p. 676, Feb. 2022.
[13] C. Xin and L. Q. Zakaria, ‘‘Integrating BERT with CNN and BiLSTM for explainable detection of depression in social media contents,’’ IEEE Access, vol. 12, pp. 161203–161212, 2024.
[14] A. A. Khaparde, R. Das, and R. Bhargava, ‘‘Transformer based approach for depression detection,’’ in Proc. 15th Int. Conf. Develop. eSystems Eng. (DeSE), Jan. 2023, pp. 369–374.
[15] M.Z.Uddin, ‘‘Depression detection in text using long short-term memory based neural structured learning,’’ in Proc. Int. Conf. Innov. Sci., Eng. Technol. (ICISET), Feb. 2022, pp. 408–414.
[16] G. K. Kamalam, S. K. Mithila, and N. M. M. Shiry, ‘‘A text-based approach for diagnosing depression using social media texts,’’ in Proc. Int. Conf. Circuit Power Comput. Technol. (ICCPCT), Aug. 2023, pp. 181–185.
[17] K. Mao, W. Zhang, D. B. Wang, A. Li, R. Jiao, Y. Zhu, B. Wu, T. Zheng, L. Qian, W. Lyu, M. Ye, and J. Chen, ‘‘Prediction of depression severity based on the prosodic and semantic features with bidirectional LSTM and time distributed CNN,’’ IEEE Trans. Affect. Comput., vol. 14, no. 3, pp. 2251–2265, Jul./Sep. 2023, doi: 10.1109/TAFFC.2022.3154332.
[18] M. Trotzek, S. Koitka, and C. M. Friedrich, ‘‘Utilizing neural networks and linguistic metadata for early detection of depression indications in text sequences,’’ IEEE Trans. Knowl. Data Eng., vol. 32, no. 3, pp. 588–601, Mar. 2020.
[19] A. Raj, Z. Ali, S. Chaudhary, K. K. Bali, and A. Sharma, ‘‘Depression detection using BERT onsocial media platforms,’’ in Proc. IEEE Int. Conf. Artif. Intell. Eng. Technol. (IICAIET), Aug. 2024, pp. 228–233.
[20] M. Hasan and S. Ghane, ‘‘Data-driven depression detection system for textual data on Twitter using deep learning,’’ in Proc. 2nd Asian Conf. Innov. Technol. (ASIANCON), Aug. 2022, pp. 1–5.
[21] S. Verma, R. C. Joshi, M. K. Dutta, S. Jezek, and R. Burget, ‘‘AI-enhanced mental health diagnosis: Leveraging transformers for early detection of depression tendency in textual data,’’ in Proc. 15th Int. Congr. Ultra Modern Telecommun. Control Syst. Workshops (ICUMT),Oct.2023,pp. 56–61.
[22] M. Kumari, G. Singh, and S. D. Pande, ‘‘Depressonify: BERT a deep learning approach of detection of depression,’’ EAI Endorsed Trans. Pervasive Health Technol., vol. 10, Mar. 2024.
[23] C. Pananookooln, J. Akaranee, and C. Silpasuwanchai, ‘‘Comparing selective masking methods for depression detection in social media,’’ Comput. Linguistics, vol. 49, no. 3, pp. 525–553, Sep. 2023.
[24] L. Ilias, S. Mouzakitis, and D. Askounis, ‘‘Calibration of transformer based models for identifying stress and depression in social media,’’ IEEE Trans. Computat. Social Syst., vol. 11, no. 2, pp. 1979–1990, Apr. 2024.
[25] C. Shen and Z. Zhao, ‘‘Detection of negative emotions and depression in social networks based on BERT-LSTM model,’’ in Proc. 2nd Int. Conf. Image, Algorithms Artificial Intell. (ICIAAI), Oct. 2024, pp. 911–920.
[26] N. Firoz, O. G. Beresteneva, and S. V. Aksyonov, ‘‘Enhancing depression detection: Employing autoencoders and linguistic feature analysis with BERT and LSTM model,’’ in Proc. Int. Russian Autom. Conf. (RusAuto Con), Sep. 2023, pp. 299–304.
[27] D. Liu, X. L. Feng, F. Ahmed, M. Shahid, and J. Guo, ‘‘Detecting and measuring depression on social media using a machine learning approach: Systematic review,’’ JMIR Mental Health, vol. 9, no. 3, Mar. 2022, Art. no. e27244.
[28] [N. A. M. Ripah, A. A. Latif, Z. C. Cob, S. M. Drus, R. M. Anwar, and H. M. Radzi, ‘‘Depression detection based on features of depressive behaviour through social media analytic: A systematic literature review,’’ in Proc. Int. Conf. Comput. Sci. Technol. Singapore: Springer, Aug. 2022, pp. 193–203.
[29] [A. Atta, D. Elsayad, D. Ezzat, S. Amin, and M. ElGamal, ‘‘Automated depression screening of clinical transcript optimized by grey wolf optimizer,’’ Int. J. Intell. Comput. Inf. Sci., vol. 24, no. 3, pp. 58–69, Sep. 2024.
[30] R. Kanani, J. Fiaidhi, and V. Patel, ‘‘Depression sentiment analysis based on social media content like Twitter,’’ Authorea Preprints, Dec. 2022.