Description
This model is a BioBERT-based Adverse Event Text Classifier and it is trained for analyzing the adverse events of drugs mentioned in health documents.
The Text Classifier model has been trained using in-house annotated health-related text that have been labeled with two different classes:
True
: Text includes signs or symptoms that are unfavorable, unintended, and/or harmful in a patient who is administered a pharmaceutical product or medical device.
False
: The patient did not experience something unfavorable during the course of treatment.
Predicted Entities
True
, False
How to use
document_assembler = DocumentAssembler()\
.setInputCol("text")\
.setOutputCol("document")
tokenizer = Tokenizer() \
.setInputCols(["document"]) \
.setOutputCol("token")
sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vop_adverse_event", "en", "clinical/models")\
.setInputCols(["document", "token"])\
.setOutputCol("prediction")
clf_Pipeline = Pipeline(stages=[
document_assembler,
tokenizer,
sequenceClassifier])
data = spark.createDataFrame([
["I am taking this medication once a day for the last 3 days. I am feeling very bad, pressure on my head, some chest pain, cramps on my neck and feel very weird. I want to reduce my blood pressure naturally. Can I stop this medication? I only took it for 5 days. I was reading here, that a lot of people has been losing weight and exercise and now they have a normal blood pressure. Please let me know, what I can do. The sides effects are horrible"],
["I go the pub about 3-4 times a week and drink quite a bit. I like socialising, been doing so for years now.Recently been getting this occasional pain from the liver area (under right ribs).It comes and goes. Could this be a sign of liver damage?When i get this pain i am usually in the pub drinking.If i press the area under my right rib cage about half way across i can feel pain. Is that pain in the Liver?"]
]).toDF("text")
result = clf_Pipeline.fit(data).transform(data)
val document_assembler =new DocumentAssembler()
.setInputCol("text")
.setOutputCol("document")
val tokenizer = new Tokenizer()
.setInputCols("document")
.setOutputCol("token")
val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_vop_adverse_event", "en", "clinical/models")
.setInputCols("token")
.setOutputCol("prediction")
val clf_Pipeline = new Pipeline().setStages(Array(document_assembler, tokenizer, sequenceClassifier))
val data = Seq(Array(
"I am taking this medication once a day for the last 3 days. I am feeling very bad, pressure on my head, some chest pain, cramps on my neck and feel very weird. I want to reduce my blood pressure naturally. Can I stop this medication? I only took it for 5 days. I was reading here, that a lot of people has been losing weight and exercise and now they have a normal blood pressure. Please let me know, what I can do. The sides effects are horrible",
"I go the pub about 3-4 times a week and drink quite a bit. I like socialising, been doing so for years now.Recently been getting this occasional pain from the liver area (under right ribs).It comes and goes. Could this be a sign of liver damage? When i get this pain i am usually in the pub drinking.If i press the area under my right rib cage about half way across i can feel pain. Is that pain in the Liver?"
)).toDS().toDF("text")
val result = clf_Pipeline.fit(data).transform(data)
Results
+------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
| text| result|
+------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
|I am taking this medication once a day for the last 3 days. I am feeling very bad, pressure on my head, some chest pain, cramps on my neck and feel...| True |
|I go the pub about 3-4 times a week and drink quite a bit. I like socialising, been doing so for years now.Recently been getting this occasional pa...| False |
+------------------------------------------------------------------------------------------------------------------------------------------------------+-------+
Model Information
Model Name: | bert_sequence_classifier_vop_adverse_event |
Compatibility: | Healthcare NLP 5.1.1+ |
License: | Licensed |
Edition: | Official |
Input Labels: | [document, token] |
Output Labels: | [prediction] |
Language: | en |
Size: | 406.4 MB |
Case sensitive: | true |
Max sentence length: | 512 |
References
In-house annotated health-related text.
Benchmarking
label precision recall f1-score support
False 0.89 0.82 0.85 277
True 0.70 0.82 0.75 146
accuracy - - 0.82 423
macro_avg 0.80 0.82 0.80 423
weighted_avg 0.83 0.82 0.82 423