Mental Health Reddit Analysis
By: Kayla Strickland
Tags: Flatiron School, Data Science, Mental Health, Python, Keras

For my capstone project at Flatiron, I wanted to see if I could predict whether someone has a specific mental health illness based on their posts about things unrelated to their mental health. My background before becoming a data scientist was in the mental health field, so I wanted to combine my new skills with my previous passion of helping those struggling with mental health related symptoms.

As you can imagine, this was a very difficult thing for a model to do. While I tried to create one large model that was able to classify users as either of the control group (no self-reported mental health diagnosis) or of six specific mental health disorders (PTSD, anxiety, depression, ADHD, bipolar, and borderline personality disorder), this proved very difficult. I ended up creating a 2 model approach — first a binary classifier that classifies users as either part of the control group, or part of the mental health group. This model was trained only on comments and posts from non-mental health specific subreddits. This model achieved an overall macro f1 score of.69, precision of .68, and recall of .7. For the mental health class, the f1-score was .59, precision was .55, and recall was .64.

hid_dim1 = 768

hid_dim2 = 384 model_bin_sbert_balanced = tf.keras.models.Sequential([

tf.keras.layers.Dense(hid_dim1, activation=tf.nn.leaky_relu), tf.keras.layers.Dense(hid_dim2, activation=tf.nn.leaky_relu), tf.keras.layers.Dense(2, activation=tf.nn.leaky_relu), tf.keras.layers.Dense(1, activation=’sigmoid’)])

I then try to classify data from the “mental health group” based on which diagnosis they may have. This of course proved very difficult to do. The first version where every class was weighted the same had a f1 score of .297. It does best with anxiety (recall of .65 and precision of .36) and PTSD (recall of .53 and precision of .36). Also interestingly, PTSD is misclassified as anxiety 473 times, and anxiety is misclassified as PTSD 358 times.

hid_dim1 = 768

hid_dim2 = 384 model_sbert_subclass = tf.keras.models.Sequential([

tf.keras.layers.Dense(hid_dim1, activation=tf.nn.leaky_relu),

tf.keras.layers.Dense(hid_dim2, activation=tf.nn.leaky_relu),

tf.keras.layers.Dense(6, activation=tf.nn.leaky_relu),

tf.keras.layers.Dense(6, use_bias=False),

tf.keras.layers.Softmax()])

The second version of the model, which took into account class weights, has a weighted f1-score of .27, precision of .32, and recall of .27. ADHD’s recall and precision are similar to each other at .25 and .27. Anxiety’s precision is .47 and recall is .17. Bipolar’s recall is .43 but precision is .2. BPD’s recall is .29 and precision is .19. Depression has a recall of .18 and precision of .17. PTSD’s recall is .34 and precision is .35. Interestingly, in this model PTSD is linked more closely to bipolar than anxiety.

This project was very much a challenge for me in so many ways. It tested my knowledge and my fortitude. It also took place as I was dealing with several life changes. I’m very proud of what I was able to create for this project, and all I have learned in my data science journey so far.