Lexicon and Naive Bayes Algorithms to Detect Mental Health Situations from Twitter Data


October 29, 2022


Background: Twitter is a popular social media where users express emotions, thoughts, and opinions that cannot be channelled in the real world. They do this by tweeting short, concise, and clear messages. Since users often express themselves, Twitter data can detect mental health trends.

Objective: This study aims to detect suicidal messages through tweets written by users with mental health issues.

Methods: These tweets are analysed and classified using the lexicon-based and Naive Bayes algorithms to determine whether it contains suicidal messages.

Results: The classification results show that the ‘normal’ classification is predominant at 52.3% of the total 3,034,826 tweets, which indicates an increase from September to December 2021.

Conclusion: Most tweets are categorised as ‘normal’, therefore the mental health status appears secure. However, this finding needs to be re-examined in the future, especially in DKI Jakarta Province, which has the most cases of mental disorders. This study found that the Naive Bayes algorithm is more accurate (85.5%) than the lexicon-based algorithm. This can be improved in future studies by increasing performance at the pre-processing stage.


Keywords: Lexicon Based, Mental Disorder, Mental Health, Naïve Bayes, Twitter