Depression Classifier (PHS-BERT)

Description

This model is a PHS-BERT based text classification model that can classify depression level of social media text into three levels: no-depression, minimum, high-depression.

Predicted Entities

no-depression, minimum, high-depression

Copy S3 URI

How to use

document_assembler = DocumentAssembler() \
    .setInputCol("text") \
    .setOutputCol("document")

tokenizer = Tokenizer() \
    .setInputCols(["document"]) \
    .setOutputCol("token")

sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_depression", "en", "clinical/models")\
    .setInputCols(["document","token"])\
    .setOutputCol("class")

pipeline = Pipeline(stages=[
    document_assembler, 
    tokenizer,
    sequenceClassifier    
])

data = spark.createDataFrame([
             ["None that I know of. Any mental health issue needs to be cared for like any other health issue. Doctors and medications can help."], 
             ["I don’t know. Was this okay? Should I hate him? Or was it just something new? I really don’t know what to make of the situation."], 
             ["It makes me so disappointed in myself because I hate what I've become and I hate feeling so helpless."]
    ]).toDF("text")

result = pipeline.fit(data).transform(data)
result.select("text", "class.result").show(truncate=False)
val documenter = new DocumentAssembler() 
    .setInputCol("text") 
    .setOutputCol("document")

val tokenizer = new Tokenizer()
    .setInputCols(Array("document"))
    .setOutputCol("token")

val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_depression", "en", "clinical/models")
    .setInputCols(Array("document","token"))
    .setOutputCol("class")

val pipeline = new Pipeline().setStages(Array(documenter, tokenizer, sequenceClassifier))

val data = Seq(Array(
             "None that I know of. Any mental health issue needs to be cared for like any other health issue. Doctors and medications can help.", 
             "I don’t know. Was this okay? Should I hate him? Or was it just something new? I really don’t know what to make of the situation.", 
             "It makes me so disappointed in myself because I hate what I've become and I hate feeling so helpless."
    )).toDS.toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.classify .bert_sequence.depression").predict("""None that I know of. Any mental health issue needs to be cared for like any other health issue. Doctors and medications can help.""")

Results

+---------------------------------------------------------------------------------------------------------------------------------+-----------------+
|text                                                                                                                             |result           |
+---------------------------------------------------------------------------------------------------------------------------------+-----------------+
|None that I know of. Any mental health issue needs to be cared for like any other health issue. Doctors and medications can help.|[no-depression]  |
|I don’t know. Was this okay? Should I hate him? Or was it just something new? I really don’t know what to make of the situation. |[minimum]        |
|It makes me so disappointed in myself because I hate what I've become and I hate feeling so helpless.                            |[high-depression]|
+---------------------------------------------------------------------------------------------------------------------------------+-----------------+

Model Information

Model Name: bert_sequence_classifier_depression
Compatibility: Healthcare NLP 4.0.2+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: en
Size: 1.3 GB
Case sensitive: true
Max sentence length: 128

Benchmarking

          label   precision     recall  f1-score   support
  no-depression        0.99       0.99      0.99        98
        minimum        0.85       0.86      0.85       155
high-depression        0.81       0.80      0.81       119
       accuracy          -          -       0.87       372
      macro-avg        0.88       0.88      0.88       372
   weighted-avg        0.87       0.87      0.87       372