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.

Definitions of Predicted Entities:

  • Age: All mention of ages, past or present, related to the patient or with anybody else.
  • Temperature: All mentions that refer to body temperature.
  • O2_Saturation: Systemic arterial, venous or peripheral oxygen saturation measurements.
  • Procedure: All mentions of invasive medical or surgical procedures or treatments.
  • Symptom: All the symptoms mentioned in the document, of a patient or someone else.
  • Substance: All mentions of substance use related to the patient or someone else (recreational drugs, illicit drugs).
  • Route: Drug and medication administration routes available described by FDA.
  • Blood_Pressure: Systemic blood pressure, mean arterial pressure, systolic and/or diastolic are extracted.
  • Allergen: Allergen related extractions mentioned in the document.
  • Gender: Gender-specific nouns and pronouns.
  • Pulse: Peripheral heart rate, without advanced information like measurement location.
  • Modifier: Terms that modify the symptoms, diseases or risk factors. If a modifier is included in ICD-10 name of a specific disease, the respective modifier is not extracted separately.
  • Frequency: Frequency of administration for a dose prescribed.
  • Weight: All mentions related to a patients weight.
  • Dosage: Quantity prescribed by the physician for an active ingredient; measurement units are available described by FDA.
  • Respiration: Number of breaths per minute.

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 Copy S3 URI

How to use

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

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

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

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

jsl_ner_converter = NerConverter() \
		.setInputCols(["sentence", "token", "jsl_ner"]) \
		.setOutputCol("ner_chunk")

jsl_ner_pipeline = Pipeline().setStages([
				documentAssembler,
				sentenceDetector,
				tokenizer,
				embeddings,
				jsl_ner,
				jsl_ner_converter])


jsl_ner_model = jsl_ner_pipeline.fit(spark.createDataFrame([[""]]).toDF("text"))

data = spark.createDataFrame([["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."]]).toDF("text")

result = jsl_ner_model.transform(data)
val documentAssembler = new DocumentAssembler()
		.setInputCol("text")
		.setOutputCol("document")

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

val tokenizer = new Tokenizer()
		.setInputCols("sentence")
		.setOutputCol("token")
	
val embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")
		.setInputCols(Array("sentence", "token"))
	    .setOutputCol("embeddings")

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

val jsl_ner_converter = new NerConverter()
		.setInputCols(Array("sentence", "token", "jsl_ner"))
		.setOutputCol("ner_chunk")

val jsl_ner_pipeline = new Pipeline().setStages(Array(
					documentAssembler, 
					sentenceDetector, 
					tokenizer, 
					embeddings, 
					jsl_ner, 
					jsl_ner_converter))


val data = Seq("""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")

val result = jsl_ner_pipeline.fit(data).transform(data)
import nlu
nlu.load("en.med_ner.jsl").predict("""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.""")

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