Description
This pretrained model maps drugs with their corresponding action
and treatment
. action
refers to the function of the drug in various body systems, treatment
refers to which disease the drug is used to treat
Predicted Entities
action
, treatment
How to use
document_assembler = DocumentAssembler()\
.setInputCol('text')\
.setOutputCol('document')
sentence_detector = SentenceDetector()\
.setInputCols(["document"])\
.setOutputCol("sentence")
tokenizer = Tokenizer()\
.setInputCols("sentence")\
.setOutputCol("token")
ner = MedicalBertForTokenClassifier.pretrained("bert_token_classifier_drug_development_trials", "en", "clinical/models")\
.setInputCols("token","sentence")\
.setOutputCol("ner")
nerconverter = NerConverterInternal()\
.setInputCols("sentence", "token", "ner")\
.setOutputCol("drug")
chunkerMapper = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models") \
.setInputCols("drug")\
.setOutputCol("relations")\
.setRel("treatment") #or action
pipeline = Pipeline().setStages([document_assembler,
sentence_detector,
tokenizer,
ner,
nerconverter,
chunkerMapper])
text = ["""
The patient is a 71-year-old female patient of Dr. X. and she was given Aklis and Dermovate.
Cureent Medications: Diprivan, Proventil
"""]
test_data = spark.createDataFrame([text]).toDF("text")
res = pipeline.fit(test_data).transform(test_data)
val document_assembler = DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentence_detector = SentenceDetector()
.setInputCols(Array("document"))
.setOutputCol("sentence")
val tokenizer = Tokenizer()
.setInputCols("sentence")
.setOutputCol("token")
val ner = MedicalBertForTokenClassifier.pretrained("bert_token_classifier_drug_development_trials", "en", "clinical/models")
.setInputCols("token","sentence")
.setOutputCol("ner")
val nerconverter = NerConverterInternal()
.setInputCols(Array("sentence", "token", "ner"))
.setOutputCol("drug")
val chunkerMapper = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models")
.setInputCols("drug")
.setOutputCol("relations")
.setRel("treatment")
val pipeline = new Pipeline().setStages(Array(document_assembler, sentence_detector, tokenizer, ner, nerconverter, chunkerMapper ))
val test_data = Seq("The patient is a 71-year-old female patient of Dr. X. and she was given Aklis and Dermovate.
Cureent Medications: Diprivan, Proventil").toDF("text")
val res = pipeline.fit(test_data).transform(test_data)
import nlu
nlu.load("en.map_entity.drug_to_action_treatment").predict("""
The patient is a 71-year-old female patient of Dr. X. and she was given Aklis and Dermovate.
Cureent Medications: Diprivan, Proventil
""")
Results
+---------+------------------+--------------------------------------------------------------+
|Drug |Treats |Pharmaceutical Action |
+---------+------------------+--------------------------------------------------------------+
|Aklis |Hyperlipidemia |Hypertension:::Diabetic Kidney Disease:::Cerebrovascular... |
|Dermovate|Lupus |Discoid Lupus Erythematosus:::Empeines:::Psoriasis:::Eczema...|
|Diprivan |Infection |Laryngitis:::Pneumonia:::Pharyngitis |
|Proventil|Addison's Disease |Allergic Conjunctivitis:::Anemia:::Ankylosing Spondylitis |
+---------+------------------+--------------------------------------------------------------+
Model Information
Model Name: | drug_action_treatment_mapper |
Compatibility: | Healthcare NLP 3.5.0+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [ner_chunk] |
Output Labels: | [mappings] |
Language: | en |
Size: | 8.7 MB |