Editing
AI for Drug Adverse Effect Detection
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== <span style="color: #FFFFFF;">Applying</span> == '''NLP extraction of adverse drug events from clinical notes:''' <syntaxhighlight lang="python"> from transformers import pipeline, AutoTokenizer, AutoModelForTokenClassification import re # BioBERT fine-tuned for ADE detection (NER on clinical text) model_name = "allenai/biomed_roberta_base" # or "d4data/biomedical-ner-all" ner_pipeline = pipeline("ner", model="allenai/biomed_roberta_base", aggregation_strategy="simple") # ADE-specific NER model (trained on ADE corpus) ade_model = AutoModelForTokenClassification.from_pretrained( "ncats/DrugProt-bioBERT-base-cased" # Drug + protein NER ) def extract_drug_ade_pairs(clinical_note: str) -> list[dict]: """Extract (drug, adverse_effect) pairs from clinical text.""" entities = ner_pipeline(clinical_note) drugs, adverse_effects = [], [] for ent in entities: if ent['entity_group'] in ['DRUG', 'CHEMICAL']: drugs.append({'text': ent['word'], 'start': ent['start'], 'end': ent['end']}) elif ent['entity_group'] in ['DISEASE', 'SYMPTOM', 'ADE']: adverse_effects.append({'text': ent['word'], 'start': ent['start']}) # Simple proximity-based relation extraction: drug + ADE within same sentence pairs = [] sentences = clinical_note.split('.') for sent in sentences: sent_drugs = [d for d in drugs if d['text'].lower() in sent.lower()] sent_aes = [a for a in adverse_effects if a['text'].lower() in sent.lower()] for drug in sent_drugs: for ae in sent_aes: pairs.append({ 'drug': drug['text'], 'adverse_effect': ae['text'], 'sentence': sent.strip() }) return pairs # Disproportionality analysis on FAERS data import pandas as pd import numpy as np def reporting_odds_ratio(faers_df: pd.DataFrame, drug: str, event: str) -> dict: """Compute ROR for drug-event pair in spontaneous reports.""" a = len(faers_df[(faers_df['drug'] == drug) & (faers_df['event'] == event)]) b = len(faers_df[(faers_df['drug'] == drug) & (faers_df['event'] != event)]) c = len(faers_df[(faers_df['drug'] != drug) & (faers_df['event'] == event)]) d = len(faers_df[(faers_df['drug'] != drug) & (faers_df['event'] != event)]) if b == 0 or c == 0: return {'ror': None, 'signal': False} ror = (a * d) / (b * c) # 95% CI on log scale se = np.sqrt(1/a + 1/b + 1/c + 1/d) ci_low = np.exp(np.log(ror) - 1.96 * se) ci_high = np.exp(np.log(ror) + 1.96 * se) signal = ror > 2.0 and ci_low > 1.0 and a >= 3 # Standard signal threshold return {'ror': ror, 'ci': (ci_low, ci_high), 'n': a, 'signal': signal} </syntaxhighlight> ; Drug safety AI tools : '''FAERS analysis''' β OpenVigil (web), FDA Sentinel System, WHO VigiBase / VigiAccess : '''EHR pharmacovigilance''' β CPRD Aurum + SCCS, Optum ClinicalAI, FDA MedWatch : '''NLP ADE extraction''' β MedEx, cTAKES, clinicalBERT NER models : '''DDI prediction''' β DDIMDL, SSI-DDI (graph learning), DrugBank + ML : '''Social media''' β Social Media Mining for Health (SMM4H), MedWatcher </div> <div style="background-color: #8B4500; color: #FFFFFF; padding: 20px; border-radius: 8px; margin-bottom: 15px;">
Summary:
Please note that all contributions to BloomWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
BloomWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
English
Views
Read
Edit
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
What links here
Related changes
Special pages
Page information