Detecting Stress in Social Media Posts: A Comparative Study of Machine Learning Algorithms and GPT-Based Classification
Abstract
Social media platforms have become a rich source of information about users’ mental well-being, including stress. This study compares a fine-tuned GPT-2 classifier with four traditional machine learning (ML) algorithms—Naïve Bayes, Decision Tree, Logistic Regression and Random Forest—for detecting stress in tweets. The experiments used the mental-health-stress Twitter dataset from Kaggle, which contains 20,001 labeled posts. After pre-processing, the posts were classified as stressed or not stressed, and all models were evaluated using accuracy, precision, recall and F1-score. The GPT-2 classifier achieved the highest accuracy (88.7%) and an F1-score of 0.89, compared with 70–78% accuracy for the traditional algorithms. These results indicate that transformer-based language models capture the contextual cues of stress in short, informal text more effectively than frequency-based classifiers. Such models could support scalable, non-invasive screening tools for mental-health monitoring, although the study is limited by its single dataset, undocumented labelling procedure and single train–test split.