🛡️ Building a Dual-Layer AI Engine for NAFDAC Drug Verification

Combining Exact Database Lookups with Machine Learning Fraud Inference for Real-Time Pharmaceutical Anti-Counterfeiting.

1. System Architecture: The Dual-Layer Verification Flow

Standard verification systems rely solely on exact string matching against government registries. However, counterfeiters frequently exploit this by using slight spelling variations or reusing authentic codes on fake packaging. To solve this, we built a Dual-Layer Verification Architecture:

🟢 Layer 1: Direct Registry Lookup (Deterministic)

Performs an instant hash/normalized check against official NAFDAC records. If an exact match is found, it immediately confirms the item as AUTHENTIC (100% Confidence) without triggering AI compute overhead.

🟡 Layer 2: Machine Learning Inference Engine (Probabilistic)

If Layer 1 misses (due to fake codes, brand spoofing, or typos), the query is routed to our TF-IDF + Random Forest Classifier (98% Accuracy) and Isolation Forest Anomaly Detector to assess structural counterfeit risk and assign a confidence score.

2. Live Testing & System Validation

We deployed the combined system using an interactive Gradio interface to simulate real-world scanning scenarios across both genuine registry entries and synthetic attack vectors.

Test Scenario Input Parameters Engine Layer Verdict
Official Registered Product DR BROWN'S ADULT DIAPER
NRN: 03-1450
Layer 1 Match 🟢 100% Authentic
Fake Code Attack Super Miracle Cure
NRN: INVALID-CODE
Layer 2 AI 🚨 Confirmed Counterfeit (2.00% Score)
Brand Spoofing Attack Paracetamol Tablets 500mg
NRN: XX-9999
Layer 2 AI 🔴 Potential Counterfeit / High Risk

💡 Project Milestone Takeaway

By coupling exact lookup speed with machine learning pattern recognition, the system provides real-time verification capable of protecting consumers against both simple unlisted products and sophisticated packaging counterfeits.

Comments

Popular posts from this blog