A high-risk category marks a medication request that requires heightened scrutiny and contact with a human pharmacist. A digital guardian system classifies text as HIGH RISK or LOW RISK: epilepsy should trigger review, while mild seasonal allergies should not. The label is therefore a routing decision, not merely a descriptive tag. section 4.6
The classification target can be derived from serious or life-threatening side-effect values. Drug descriptions and side effects are combined, tokenized, and transformed into vectors before a deep-learning classifier predicts the category. This shortcut hides important failure modes: incomplete fields reduce the usable dataset, and strong aggregate accuracy does not guarantee safe high-risk detection. section 4.6.1 section 4.6.3
A dangerous false negative
A long description for a prescription medicine used for epilepsy received a risk probability of 0.21. With a 0.5 threshold, the system incorrectly returned LOW RISK. Shortening the inputs and lowering the threshold to 0.3 produced 0.82 and HIGH RISK for an anxiety example, while the mild-allergy example remained LOW RISK at 0.01. Threshold changes improve this demonstration but do not replace validation focused on high-risk errors. section 4.6.4
Listing 4.7 The classes distribution
Class distribution:
High_Risk
0 4848
1 2640
Name: count, dtype: int64
High_Risk
0 0.647436
1 0.352564
Name: proportion, dtype: float64
class_weight: {0: 0.7723053120165033, 1: 1.418087121212121}
Inspect the class distribution and class weights before interpreting model performance; the labeled data contains 35.3% high-risk records. section 4.6.3
Listing 4.10 Classification output
========== FINAL MODEL DEMO ========== --- LOW RISK EXAMPLE --- Risk Probability: 0.07 Predicted Risk Level: LOW RISK ✅ --- HIGH RISK EXAMPLE --- Risk Probability: 0.21 Predicted Risk Level: LOW RISK ✅
Compare the model's probability with its threshold and expose the high-risk false negative in the final demonstration. section 4.6.4
