Looking at a 2018 report from the American Psychological Association (APA), it can be seen that across the different generations, the proportion of depressive disorders is steadily increasing. While only about 12% of the Boomer generation reported suffering from a diagnosed depression, this figure has risen to 15% among Millennials and 23% among Gen Z respondents (APA Report). Following the data of AOK health magazine, one cause of depression may be comparing oneself and the world in which one lives with the optimized and sometimes embellished self-portrayals of other users can have a strong impact on self-esteem and lead to dejection and depressed moods. Social media in particular, and the comparison with others that goes with it, can trigger for depressive tendencies.

For this reason, we have developed an app that rates social media posts and gives a depression classification. If depressive signs have been detected, the app offers contact points for help. The fact that the number of depressed people has steadily increased over the years and the assumption that depression still has a very high underreporting rate inspired us to start in a place where depression can be triggered. Therefore, we came up with the idea to develop an application that detects depressive tendencies in social media posts and displays them visually to the user. In this way we want to give users an external reflection which can be a reason and starting point to seek help. In addition, our application is also intended for people who are worried about their friends, who can better assess them through our application and can stand by their friends with help.

What it does

In our application, text in Twitter post length can be entered, from which features such as emotions, sentiments and topics are extracted in the backend with NL API. Based on these features, a machine learning model is triggered which performs an improved depression detection based on the extracted features. In addition, the analyses from NL API are displayed as a supplement in the dashboard. As a result, the user is then shown whether a depression was detected or not. If a depression is detected, the user is shown contact points to seek help. In the advanced model, a WordCloud is also displayed in which the extracted emotions can be seen.

How we built it

For the machine learning model, we first gathered various data sources from kaggle. Then we trained and evaluated a naive bayes model with this data. Two models were used in the process. In the first model, only the text of the posts were used for classification. In a second model, we extracted features such as sentiments, emotions, and topics using and passed them into our model. With this we implemented a feature extraction upstream to use the extracted features in the model. After that, we were able to compare the two models. Uisng the implementation in the future, the additional features can be used for more advanced machine learning models and to make the machine learning models more interpretable (for example, a tweet might be classified as depressived because emotions such as sadness or fear are recognized in a tweet).

Challenges we ran into

As in any machine learning project, the question of data was at the beginning. Fortunately, we were able to establish an exemplary database containing tweet text and depression labels from Kaggle. Another problem was the initial extraction of the features with, since the extraction of all required features on our database quickly exceeded the trial characters of Often the API did not keep up with the number of requests or threw errors for some reason that we had to catch in our code.

Accomplishments that we're proud of

With the algorithm we implemented within two weeks, we can compete with other models that classify posts from Twitter and Facebook that have introduced similar algorithms for depression detection. Decisive for this was the previous feature extraction with

What we learned provides easy-to-set-up and easy-to-use toolset for extracting features from text in ML.

What's next for Tweet Depression Detector

Now that the potential of the extracted features with is known, the next step is to implement further algorithms for classification. In addition, the classifier will be extended by the possibility to directly access the posts of a Twitter user via the name of a Twitter user and a Twitter API and to derive an even better prediction for the depression classification.

Built With

Share this project: