Assertion Status for Voice of the Patients (embeddings_clinical_large)

Description

Assertion status model used to predict if an NER chunk refers to a positive finding from the patient (Present_Or_Past), or if it refers to a family member or another person (SomeoneElse) or if it is mentioned but not as something present (Hypothetical_Or_Absent).

This model is the final version of the WIP assertion model.

Predicted Entities

Hypothetical_Or_Absent, Present_Or_Past, SomeoneElse

Copy S3 URI

How to use

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

sentence_detector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare", "en", "clinical/models")\
    .setInputCols(["document"])\
    .setOutputCol("sentence")

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

word_embeddings = WordEmbeddingsModel().pretrained("embeddings_clinical_large", "en", "clinical/models")\
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("embeddings")

ner = MedicalNerModel.pretrained("ner_vop_emb_clinical_large", "en", "clinical/models") \
    .setInputCols(["sentence", "token", "embeddings"]) \
    .setOutputCol("ner")

ner_converter = NerConverterInternal() \
    .setInputCols(["sentence", "token", "ner"]) \
    .setOutputCol("ner_chunk")

assertion = AssertionDLModel.pretrained("assertion_vop_clinical_large", "en", "clinical/models") \
    .setInputCols(["sentence", "ner_chunk", "embeddings"]) \
    .setOutputCol("assertion")

pipeline = Pipeline(stages=[document_assembler,
                            sentence_detector,
                            tokenizer,
                            word_embeddings,
                            ner,
                            ner_converter,
                            assertion])

data = spark.createDataFrame([["I was feeling anxiety honestly. Can it bring on tremors? It was right after my friend was diagnosed with diabetes."]]).toDF("text")

result = pipeline.fit(data).transform(data)
val document_assembler = new DocumentAssembler()
    .setInputCol("text")
    .setOutputCol("document")

val sentence_detector = SentenceDetectorDLModel.pretrained("sentence_detector_dl_healthcare", "en", "clinical/models")
    .setInputCols("document")
    .setOutputCol("sentence")

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

val word_embeddings = WordEmbeddingsModel().pretrained("embeddings_clinical_large", "en", "clinical/models")
    .setInputCols(Array("sentence", "token"))
    .setOutputCol("embeddings")

val ner = MedicalNerModel.pretrained("ner_vop_emb_clinical_large", "en", "clinical/models")
    .setInputCols(Array("sentence", "token", "embeddings"))
    .setOutputCol("ner")

val ner_converter = new NerConverterInternal()
    .setInputCols(Array("sentence", "token", "ner"))
    .setOutputCol("ner_chunk")

val assertion = AssertionDLModel.pretrained("assertion_vop_clinical_large", "en", "clinical/models")
    .setInputCols("sentence","ner_chunk","embeddings")
    .setOutputCol("assertion")

val pipeline = new Pipeline().setStages(Array(document_assembler,
                                              sentence_detector,
                                              tokenizer,
                                              word_embeddings,
                                              ner,
                                              ner_converter,
                                              assertion))

val data = Seq("I was feeling anxiety honestly. Can it bring on tremors? It was right after my friend was diagnosed with diabetes.").toDS.toDF("text")

val result = pipeline.fit(data).transform(data)

Results

+--------+-----+---+----------------------+-------+----------------------+----------+
|chunk   |begin|end|ner_label             |sent_id|assertion             |confidence|
+--------+-----+---+----------------------+-------+----------------------+----------+
|anxiety |14   |20 |PsychologicalCondition|0      |Present_Or_Past       |0.9853    |
|tremors |48   |54 |Symptom               |1      |Hypothetical_Or_Absent|0.9998    |
|diabetes|105  |112|Disease               |2      |SomeoneElse           |0.9916    |
+--------+-----+---+----------------------+-------+----------------------+----------+

Model Information

Model Name: assertion_vop_clinical_large
Compatibility: Healthcare NLP 5.0.1+
License: Licensed
Edition: Official
Input Labels: [document, chunk, embeddings]
Output Labels: [assertion]
Language: en
Size: 940.7 KB

Benchmarking

                 label  precision    recall  f1-score   support
Hypothetical_Or_Absent       0.77      0.78      0.78      1265
       Present_Or_Past       0.88      0.89      0.89      2873
           SomeoneElse       0.92      0.87      0.90      1084
              accuracy       -         -         0.86      5222
             macro_avg       0.86      0.85      0.85      5222
          weighted_avg       0.86      0.86      0.86      5222