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")
word_embeddings = WordEmbeddingsModel.pretrained("embeddings_clinical", "en", "clinical/models")\
.setInputCols(["sentence", "token"])\
.setOutputCol("embeddings")
clinical_ner = MedicalNerModel.pretrained("ner_posology_small", "en", "clinical/models")\
.setInputCols(["sentence","token","embeddings"])\
.setOutputCol("ner")\
.setLabelCasing("upper")
ner_converter = NerConverter()\
.setInputCols(["sentence", "token", "ner"])\
.setOutputCol("ner_chunk")\
.setWhiteList(["DRUG"])
chunkerMapper_action = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models")\
.setInputCols(["ner_chunk"])\
.setOutputCol("action_mappings")\
.setRels(["action"])\
.setLowerCase(True)
chunkerMapper_treatment = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models")\
.setInputCols(["ner_chunk"])\
.setOutputCol("treatment_mappings")\
.setRels(["treatment"])\
.setLowerCase(True)
pipeline = Pipeline().setStages([document_assembler,
sentence_detector,
tokenizer,
word_embeddings,
clinical_ner,
ner_converter,
chunkerMapper_action,
chunkerMapper_treatment])
model = pipeline.fit(spark.createDataFrame([[""]]).toDF("text"))
text = """The patient is a 71-year-old female patient of Dr. X. and she was given Aklis, Dermovate, Aacidexam and Paracetamol."""
pipeline = LightPipeline(model)
result = pipeline.fullAnnotate(text)
val document_assembler = new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val sentence_detector = new SentenceDetector()
.setInputCols("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 clinical_ner = MedicalNerModel.pretrained("ner_posology_small","en","clinical/models")
.setInputCols(Array("sentence","token","embeddings"))
.setOutputCol("ner")
.setLabelCasing("upper")
val ner_converter = new NerConverter()
.setInputCols(Array("sentence", "token", "ner"))
.setOutputCol("ner_chunk")
.setWhiteList(Array("DRUG"))
val chunkerMapper_action = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models")
.setInputCols(Array("ner_chunk"))
.setOutputCol("action_mappings")
.setRels(Array("action"))
.setLowerCase(True)
val chunkerMapper_treatment = ChunkMapperModel.pretrained("drug_action_treatment_mapper", "en", "clinical/models")
.setInputCols(Array("ner_chunk"))
.setOutputCol("treatment_mappings")
.setRels(Array("treatment"))
.setLowerCase(True)
val pipeline = new Pipeline().setStages(Array(
document_assembler,
sentence_detector,
tokenizer,
word_embeddings,
clinical_ner,
ner_converter,
chunkerMapper_action,
chunkerMapper_treatment))
val data = Seq("""The patient is a 71-year-old female patient of Dr. X. and she was given Aklis, Dermovate, Aacidexam and Paracetamol.""").toDS.toDF("text")
val result= pipeline.fit(data).transform(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, Dermovate, Aacidexam and Paracetamol.""")
Results
+-----------+--------------------+-------------------+------------------------------------------------------------+-----------------------------------------------------------------------------+
|Drug |action_mappings |treatment_mappings |action_meta |treatment_meta |
+-----------+--------------------+-------------------+------------------------------------------------------------+-----------------------------------------------------------------------------+
|Aklis |cardioprotective |hyperlipidemia |hypotensive:::natriuretic |hypertension:::diabetic kidney disease:::cerebrovascular accident:::smoking |
|Dermovate |anti-inflammatory |lupus |corticosteroids::: dermatological preparations:::very strong|discoid lupus erythematosus:::empeines:::psoriasis:::eczema |
|Aacidexam |antiallergic |abscess |antiexudative:::anti-inflammatory:::anti-shock |brain abscess:::agranulocytosis:::adrenogenital syndrome |
|Paracetamol|analgesic |arthralgia |anti-inflammatory:::antipyretic:::pain reliever |period pain:::pain:::sore throat:::headache:::influenza:::toothache |
+-----------+--------------------+-------------------+------------------------------------------------------------+-----------------------------------------------------------------------------+
Model Information
Model Name: | drug_action_treatment_mapper |
Compatibility: | Healthcare NLP 3.5.3+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [ner_chunk] |
Output Labels: | [mappings] |
Language: | en |
Size: | 8.4 MB |