Why & How We Generated Synthetic Counterfeit Data for AI Drug Verification
1. The "Why": Solving the Positive-Class Bias Problem
When building an AI system to detect counterfeit pharmaceuticals, you face an immediate data challenge: official government registries (like the NAFDAC Greenbook) only record authentic, approved products.
If you train a Machine Learning model exclusively on genuine drug records:
- The AI Learns Nothing About Fraud: It only sees "good" data, so it defaults to predicting that every drug is 100% authentic.
- Extreme Class Imbalance: Without negative samples (counterfeits), supervised classifiers like Random Forest cannot establish a decision boundary to separate genuine products from fraudulent ones.
To teach an AI how to spot fake drugs, you must show it what fake drugs look like. Because there is no public "official database of counterfeit drugs," generating a controlled, realistic synthetic dataset is the standard engineering solution.
2. The "How": Adversarial Synthetic Attack Generation
We took the 8,608 verified NAFDAC records (labeled as Label = 1) and generated an equal set of 8,608 realistic counterfeit attacks (labeled as Label = 0).
To make the synthetic data reflect real-world fraud, we applied four distinct adversarial attack vectors:
-
Fake & Corrupted NRNs: Replacing valid NAFDAC Registration Numbers with invalid patterns, bad prefixes, or malformed characters (e.g., swapping official formats with
XX-9999orINVALID-CODE). - Brand Spoofing & Mismatched Manufacturers: Pairing legitimate, highly recognizable drug names with unauthorized, unknown, or mismatched manufacturer names (simulating illicit labs copying popular brands).
- Typographic Mutations (Typo Attacks): Introducing subtle spelling alterations into product names (e.g., mutating Paracetamol to Paracetaml), mimicking the typos commonly found on counterfeit packaging.
- Revoked / Expired Status Vectors: Simulating revoked or expired registration structures to catch outdated codes being reused on fake packaging.
3. The Result: A Balanced AI Benchmark
By combining the 8,608 authentic records with the 8,608 synthetic attack vectors, we created a perfectly balanced 17,216-row dataset (50% Genuine / 50% Counterfeit).
This balanced structure enabled our TF-IDF + Random Forest model to achieve a 98.00% detection accuracy with high precision and recall, ensuring the AI can flag subtle packaging and registration discrepancies in real time.
Comments
Post a Comment