Detect Clinical Entities (ner_jsl)

Description

Pretrained named entity recognition deep learning model for clinical terminology. The SparkNLP deep learning model (MedicalNerModel) is inspired by a former state of the art model for NER: Chiu & Nicols, Named Entity Recognition with Bidirectional LSTM-CNN.

Predicted Entities

Diagnosis, Procedure_Name, Lab_Result, Procedure, Procedure_Findings, O2_Saturation, Procedure_incident_description, Dosage, Causative_Agents_(Virus_and_Bacteria), Name, Cause_of_death, Substance_Name, Weight, Symptom_Name, Maybe, Modifier, Blood_Pressure, Frequency, Gender, Drug_incident_description, Age, Drug_Name, Temperature, Section_Name, Route, Negation, Negated, Allergenic_substance, Lab_Name, Respiratory_Rate.

Live Demo Open in Colab Download

How to use

...
embeddings_clinical = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")\
  .setInputCols(["sentence", "token"])\
  .setOutputCol("embeddings")
clinical_ner = MedicalNerModel.pretrained("ner_jsl", "en", "clinical/models") \
  .setInputCols(["sentence", "token", "embeddings"]) \
  .setOutputCol("ner")
...
nlpPipeline = Pipeline(stages=[document_assembler, sentence_detector, tokenizer, embeddings_clinical, clinical_ner, ner_converter])

model = nlpPipeline.fit(spark.createDataFrame([[""]]).toDF("text"))
results = model.transform(spark.createDataFrame(pd.DataFrame({"text": ["""The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature."""]})))
...
val embeddings_clinical = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")
  .setInputCols(Array("sentence", "token"))
  .setOutputCol("embeddings")
val ner = MedicalNerModel.pretrained("ner_jsl", "en", "clinical/models") 
  .setInputCols("sentence", "token", "embeddings")
  .setOutputCol("ner")
...
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, embeddings_clinical, ner, ner_converter))

val result = pipeline.fit(Seq.empty["The patient is a 21-day-old Caucasian male here for 2 days of congestion - mom has been suctioning yellow discharge from the patient's nares, plus she has noticed some mild problems with his breathing while feeding (but negative for any perioral cyanosis or retractions). One day ago, mom also noticed a tactile temperature and gave the patient Tylenol. Baby also has had some decreased p.o. intake. His normal breast-feeding is down from 20 minutes q.2h. to 5 to 10 minutes secondary to his respiratory congestion. He sleeps well, but has been more tired and has been fussy over the past 2 days. The parents noticed no improvement with albuterol treatments given in the ER. His urine output has also decreased; normally he has 8 to 10 wet and 5 dirty diapers per 24 hours, now he has down to 4 wet diapers per 24 hours. Mom denies any diarrhea. His bowel movements are yellow colored and soft in nature."].toDS.toDF("text")).transform(data)

Results

+---------------------------+------------+
|chunk                      |ner         |
+---------------------------+------------+
|21-day-old                 |Age         |
|male                       |Gender      |
|congestion                 |Symptom_Name|
|mom                        |Gender      |
|suctioning yellow discharge|Symptom_Name|
|she                        |Gender      |
|mild                       |Modifier    |
|problems with his breathing|Symptom_Name|
|negative                   |Negated     |
|perioral cyanosis          |Symptom_Name|
|retractions                |Symptom_Name|
|mom                        |Gender      |
|Tylenol                    |Drug_Name   |
|His                        |Gender      |
|his                        |Gender      |
|respiratory congestion     |Symptom_Name|
|He                         |Gender      |
|tired                      |Symptom_Name|
|fussy                      |Symptom_Name|
|albuterol                  |Drug_Name   |
+---------------------------+------------+

Model Information

Model Name: ner_jsl
Compatibility: Spark NLP for Healthcare 3.0.0+
License: Licensed
Edition: Official
Input Labels: [sentence, token, embeddings]
Output Labels: [ner]
Language: en

Data Source

Trained on data gathered and manually annotated by John Snow Labs. https://www.johnsnowlabs.com/data/

Benchmarking

|    | label                                   |     tp |     fp |    fn |      prec |        rec |        f1 |
|---:|:----------------------------------------|-------:|-------:|------:|----------:|-----------:|----------:|
|  0 | B-Pulse_Rate                            |     77 |     39 |    12 | 0.663793  | 0.865169   | 0.75122   |
|  1 | I-Diagnosis                             |   2134 |   1139 |  1329 | 0.652001  | 0.616229   | 0.63361   |
|  2 | I-Procedure_Name                        |   2335 |   1329 |   956 | 0.637282  | 0.709511   | 0.671459  |
|  3 | B-Lab_Result                            |    601 |    182 |    94 | 0.767561  | 0.864748   | 0.813261  |
|  4 | B-Procedure                             |      1 |      0 |     5 | 1         | 0.166667   | 0.285714  |
|  5 | B-Procedure_Findings                    |      2 |     13 |    72 | 0.133333  | 0.027027   | 0.0449438 |
|  6 | B-O2_Saturation                         |      1 |      3 |     4 | 0.25      | 0.2        | 0.222222  |
|  7 | B-Dosage                                |    477 |    197 |    68 | 0.707715  | 0.875229   | 0.782609  |
|  8 | I-Causative_Agents_(Virus_and_Bacteria) |     12 |      2 |     7 | 0.857143  | 0.631579   | 0.727273  |
|  9 | B-Name                                  |    562 |    268 |   554 | 0.677108  | 0.503584   | 0.577595  |
| 10 | I-Cause_of_death                        |      9 |      5 |    11 | 0.642857  | 0.45       | 0.529412  |
| 11 | I-Substance_Name                        |     24 |     34 |    54 | 0.413793  | 0.307692   | 0.352941  |
| 12 | I-Name                                  |    716 |    377 |   710 | 0.655078  | 0.502104   | 0.56848   |
| 13 | B-Cause_of_death                        |      9 |      6 |     8 | 0.6       | 0.529412   | 0.5625    |
| 14 | B-Weight                                |     52 |     22 |     9 | 0.702703  | 0.852459   | 0.77037   |
| 15 | B-Symptom_Name                          |   4364 |   1916 |  1652 | 0.694904  | 0.725399   | 0.709824  |
| 16 | I-Maybe                                 |     27 |     51 |    61 | 0.346154  | 0.306818   | 0.325301  |
| 17 | I-Symptom_Name                          |   2073 |   1492 |  2348 | 0.581487  | 0.468898   | 0.519159  |
| 18 | B-Modifier                              |   1573 |    890 |   768 | 0.638652  | 0.671935   | 0.654871  |
| 19 | B-Blood_Pressure                        |     76 |     19 |    13 | 0.8       | 0.853933   | 0.826087  |
| 20 | B-Frequency                             |    308 |    134 |    77 | 0.696833  | 0.8        | 0.744861  |
| 21 | I-Gender                                |     26 |     31 |    28 | 0.45614   | 0.481482   | 0.468468  |
| 22 | I-Drug_incident_description             |      4 |     10 |    57 | 0.285714  | 0.0655738  | 0.106667  |
| 23 | B-Drug_incident_description             |      2 |      5 |    23 | 0.285714  | 0.08       | 0.125     |
| 24 | I-Age                                   |      5 |      0 |     9 | 1         | 0.357143   | 0.526316  |
| 25 | B-Drug_Name                             |   1741 |    490 |   290 | 0.780368  | 0.857213   | 0.816987  |
| 26 | B-Substance_Name                        |    148 |     41 |    48 | 0.783069  | 0.755102   | 0.768831  |
| 27 | B-Temperature                           |     56 |     23 |    13 | 0.708861  | 0.811594   | 0.756757  |
| 28 | I-Procedure                             |      1 |      0 |     7 | 1         | 0.125      | 0.222222  |
| 29 | B-Section_Name                          |   2711 |    317 |   166 | 0.89531   | 0.942301   | 0.918205  |
| 30 | I-Route                                 |    119 |    110 |   189 | 0.519651  | 0.386364   | 0.443203  |
| 31 | B-Maybe                                 |    143 |     80 |   127 | 0.641256  | 0.52963    | 0.580122  |
| 32 | B-Gender                                |   5166 |    709 |    58 | 0.879319  | 0.988897   | 0.930895  |
| 33 | I-Dosage                                |    434 |    196 |    87 | 0.688889  | 0.833013   | 0.754127  |
| 34 | B-Causative_Agents_(Virus_and_Bacteria) |     19 |      3 |     8 | 0.863636  | 0.703704   | 0.77551   |
| 35 | I-Frequency                             |    275 |    134 |   191 | 0.672372  | 0.590129   | 0.628571  |
| 36 | B-Age                                   |    357 |     27 |    16 | 0.929688  | 0.957105   | 0.943197  |
| 37 | I-Lab_Result                            |     45 |     78 |   152 | 0.365854  | 0.228426   | 0.28125   |
| 38 | B-Negation                              |     99 |     38 |    38 | 0.722628  | 0.722628   | 0.722628  |
| 39 | B-Diagnosis                             |   2786 |   1342 |   913 | 0.674903  | 0.753177   | 0.711895  |
| 40 | I-Section_Name                          |   3885 |   1353 |   179 | 0.741695  | 0.955955   | 0.835304  |
| 41 | B-Route                                 |    421 |    217 |   166 | 0.659875  | 0.717206   | 0.687347  |
| 42 | I-Negation                              |     11 |     30 |    24 | 0.268293  | 0.314286   | 0.289474  |
| 43 | B-Procedure_Name                        |   1490 |    811 |   522 | 0.647545  | 0.740557   | 0.690934  |
| 44 | B-Negated                               |   1490 |    332 |   215 | 0.817783  | 0.8739     | 0.844911  |
| 45 | I-Allergenic_substance                  |      1 |      0 |    12 | 1         | 0.0769231  | 0.142857  |
| 46 | I-Negated                               |     89 |    132 |   146 | 0.402715  | 0.378723   | 0.390351  |
| 47 | I-Procedure_Findings                    |      2 |     31 |   283 | 0.0606061 | 0.00701754 | 0.0125786 |
| 48 | B-Allergenic_substance                  |     72 |     29 |    24 | 0.712871  | 0.75       | 0.730965  |
| 49 | I-Weight                                |     47 |     35 |    16 | 0.573171  | 0.746032   | 0.648276  |
| 50 | B-Lab_Name                              |    804 |    290 |   122 | 0.734918  | 0.868251   | 0.79604   |
| 51 | I-Modifier                              |     99 |     73 |   422 | 0.575581  | 0.190019   | 0.285714  |
| 52 | I-Temperature                           |      1 |      0 |    14 | 1         | 0.0666667  | 0.125     |
| 53 | I-Drug_Name                             |    362 |    284 |   261 | 0.560372  | 0.581059   | 0.570528  |
| 54 | I-Lab_Name                              |    284 |    194 |   127 | 0.594142  | 0.690998   | 0.63892   |
| 55 | B-Respiratory_Rate                      |     46 |      5 |     5 | 0.901961  | 0.901961   | 0.901961  |
| 56 | Macro-average                           | 38674  | 15571  | 13819 | 0.589085  | 0.515426   | 0.5498    |
| 57 | Micro-average                           | 38674  | 15571  | 13819 | 0.712951  | 0.736746   | 0.724653  |