Adverse Drug Events Classifier (BERT)

Description

Classify texts/sentences in two categories:

  • True : The sentence is talking about a possible ADE.

  • False : The sentence doesn’t have any information about an ADE.

This model is a BioBERT-based classifier.

Predicted Entities

True, False

Live Demo Open in Colab Copy S3 URI

How to use

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


tokenizer = Tokenizer() \
.setInputCols(["document"]) \
.setOutputCol("token")


sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_ade", "en", "clinical/models")\
.setInputCols(["document","token"])\
.setOutputCol("class")


pipeline = Pipeline(stages=[
document_assembler, 
tokenizer,
sequenceClassifier    
])


data = spark.createDataFrame([["I felt a bit drowsy and had blurred vision after taking Aspirin."]]).toDF("text")


result = pipeline.fit(data).transform(data)
val documenter = new DocumentAssembler() 
.setInputCol("text") 
.setOutputCol("document")


val tokenizer = new Tokenizer()
.setInputCols("sentences")
.setOutputCol("token")


val sequenceClassifier = MedicalBertForSequenceClassification.pretrained("bert_sequence_classifier_ade", "en", "clinical/models")
.setInputCols(Array("document","token"))
.setOutputCol("class")


val pipeline = new Pipeline().setStages(Array(documenter, tokenizer, sequenceClassifier))


val data = Seq("I felt a bit drowsy and had blurred vision after taking Aspirin.").toDF("text")


val result = pipeline.fit(data).transform(data)
import nlu
nlu.load("en.classify.ade.seq_biobert").predict("""I felt a bit drowsy and had blurred vision after taking Aspirin.""")

Results

+----------------------------------------------------------------+------+
|text                                                            |result|
+----------------------------------------------------------------+------+
|I felt a bit drowsy and had blurred vision after taking Aspirin.|[True]|
+----------------------------------------------------------------+------+

Model Information

Model Name: bert_sequence_classifier_ade
Compatibility: Healthcare NLP 3.4.1+
License: Licensed
Edition: Official
Input Labels: [document, token]
Output Labels: [class]
Language: en
Size: 406.0 MB
Case sensitive: true
Max sentence length: 128

References

This model is trained on a custom dataset comprising of CADEC, DRUG-AE and Twimed.

Benchmarking

label  precision  recall  f1-score  support
False       0.97    0.97      0.97     6884
True       0.87    0.85      0.86     1398
accuracy       0.95    0.95      0.95     8282
macro-avg       0.92    0.91      0.91     8282
weighted-avg       0.95    0.95      0.95     8282