Detect Assertion Status from Oncology Tests

Description

This model detects the assertion status of oncology tests, such as Pathology_Test or Imaging_Test. The model identifies if the test has been performed (Present_Or_Past status), or if it is mentioned but in hypothetical or absent sentences (Hypothetical_Or_Absent status).

Predicted Entities

Hypothetical_Or_Absent, Medical_History

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", "en", "clinical/models")\
    .setInputCols(["sentence", "token"]) \
    .setOutputCol("embeddings")                

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

ner_converter = NerConverter() \
    .setInputCols(["sentence", "token", "ner"]) \
    .setOutputCol("ner_chunk")\    
    .setWhiteList(["Pathology_Test", "Imaging_Test"])
    
assertion = AssertionDLModel.pretrained("assertion_oncology_test_binary", "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([["The result of the biopsy was positive. We recommend to perform a CT scan."]]).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(Array("document"))
    .setOutputCol("sentence")
    
val tokenizer = new Tokenizer()
    .setInputCols(Array("sentence"))
    .setOutputCol("token")
    
val word_embeddings = WordEmbeddingsModel().pretrained("embeddings_clinical", "en", "clinical/models")
    .setInputCols(Array("sentence", "token"))
    .setOutputCol("embeddings")                
    
val ner = MedicalNerModel.pretrained("ner_oncology_wip", "en", "clinical/models")
    .setInputCols(Array("sentence", "token", "embeddings"))
    .setOutputCol("ner")
    
val ner_converter = new NerConverter()
    .setInputCols(Array("sentence", "token", "ner"))
    .setOutputCol("ner_chunk")
    .setWhiteList(Array("Pathology_Test", "Imaging_Test"))

val clinical_assertion = AssertionDLModel.pretrained("assertion_oncology_test_binary","en","clinical/models")
    .setInputCols(Array("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("""The result of the biopsy was positive. We recommend to perform a CT scan.""").toDF("text")

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

Results

| chunk   | ner_label      | assertion              |
|:--------|:---------------|:-----------------------|
| biopsy  | Pathology_Test | Medical_History        |
| CT scan | Imaging_Test   | Hypothetical_Or_Absent |

Model Information

Model Name: assertion_oncology_test_binary
Compatibility: Healthcare NLP 5.4.0+
License: Licensed
Edition: Official
Input Labels: [document, chunk, embeddings]
Output Labels: [assertion_pred]
Language: en
Size: 1.4 MB

References

In-house annotated oncology case reports.

Benchmarking

                 label  precision  recall  f1-score  support
Hypothetical_Or_Absent       0.79    0.81      0.80     37.0
       Medical_History       0.80    0.78      0.79     36.0
             macro-avg       0.79    0.79      0.79     73.0
          weighted-avg       0.79    0.79      0.79     73.0