Description
This model detects the assertion status of the Smoking_Status entity. It classifies extractions as Absent
, Past
or Present
.
Predicted Entities
Absent
, Past
, Present
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(["Smoking_Status"])
assertion = AssertionDLModel.pretrained("assertion_oncology_smoking_status", "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 patient quit smoking three years ago."]]).toDF("text")
result = pipeline.fit(data).transform(data)
```scala
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("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("Smoking_Status"))
val clinical_assertion = AssertionDLModel.pretrained("assertion_oncology_smoking_status","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 patient quit smoking three years ago.""").toDF("text")
val result = pipeline.fit(data).transform(data)
Results
| chunk | ner_label | assertion |
|:--------|:---------------|:------------|
| smoking | Smoking_Status | Past |
Model Information
Model Name: | assertion_oncology_smoking_status |
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
Absent 0.58 0.94 0.71 16.0
Past 0.88 0.65 0.75 23.0
Present 0.80 0.57 0.67 14.0
macro-avg 0.75 0.72 0.71 53.0
weighted-avg 0.77 0.72 0.72 53.0