Self Reported Stress Classifier (BioBERT)

Description

This model is a BioBERT based classifier that can identify stress in social media (Twitter) posts in the self-disclosure category. The model finds whether a person claims he/she is stressed or not.

Predicted Entities

not-stressed, stressed

Live Demo Open in Colab 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_self_reported_stress_tweet", "en", "clinical/models")\
    .setInputCols(["document",'token'])\
    .setOutputCol("class")

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

data = spark.createDataFrame([["Do you feel stressed?"], 
                              ["I'm so stressed!"],
                              ["Depression and anxiety will probably end up killing me – I feel so stressed all the time and just feel awful."], 
                              ["Do you enjoy living constantly in this self-inflicted stress?"]]).toDF("text")
                              
result = pipeline.fit(data).transform(data)

result.select("text", "class.result").show(truncate=False)
val document_assembler = new DocumentAssembler() 
    .setInputCol("text") 
    .setOutputCol("document")

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

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

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

val data = Seq(Array("Do you feel stressed!", 
                     "I'm so stressed!",
                     "Depression and anxiety will probably end up killing me – I feel so stressed all the time and just feel awful.", 
                     "Do you enjoy living constantly in this self-inflicted stress?")).toDS.toDF("text")

val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.classify.self_reported_stress").predict("""Depression and anxiety will probably end up killing me – I feel so stressed all the time and just feel awful.""")

Results

+-------------------------------------------------------------------------------------------------------------+--------------+
|text                                                                                                         |result        |
+-------------------------------------------------------------------------------------------------------------+--------------+
|Do you feel stressed?                                                                                        |[not-stressed]|
|I'm so stressed!                                                                                             |[stressed]    |
|Depression and anxiety will probably end up killing me – I feel so stressed all the time and just feel awful.|[stressed]    |
|Do you enjoy living constantly in this self-inflicted stress?                                                |[not-stressed]|
+-------------------------------------------------------------------------------------------------------------+--------------+

Model Information

Model Name: bert_sequence_classifier_self_reported_stress_tweet
Compatibility: Healthcare NLP 4.0.0+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: en
Size: 406.5 MB
Case sensitive: true
Max sentence length: 128

Benchmarking

       label  precision    recall  f1-score   support
not-stressed     0.8564    0.8020    0.8283       409
    stressed     0.7197    0.7909    0.7536       263
    accuracy        -         -      0.7976       672
   macro-avg     0.7881    0.7964    0.7910       672
weighted-avg     0.8029    0.7976    0.7991       672