British American Tobacco

Sales Compliance Detector

An unsupervised machine learning pipeline combining K-Means clustering with statistical outlier detection to identify non-compliant sales behaviour across a 300,000-outlet retail network — protecting incentive payouts and strengthening the integrity of trade marketing reporting.

Python K-Means Scikit-learn pandas Power BI Anomaly Detection

The Challenge

BAT ran a large-scale trade incentive programme that rewarded retail outlets for achieving sales targets and compliance with merchandising standards. With ~300,000 outlets in scope, manual auditing was not feasible — the team relied on self-reported field data to validate claims.

This created an obvious vulnerability: without automated detection, non-compliant outlets could claim incentive payouts they had not legitimately earned. Beyond the direct financial exposure, inaccurate compliance data was feeding into strategic decisions about where to invest field resources — meaning the problem had compounding downstream effects.

Approach

I built a two-stage detection pipeline that combined unsupervised clustering with statistical outlier analysis:

  • Feature engineering: Constructed behavioural features per outlet — including sales volume consistency, claim frequency, claim timing relative to audit cycles, and deviation from category norms for similar outlet types.
  • K-Means clustering: Segmented outlets into behavioural groups. Outlets in clusters with atypical claim-to-sales ratios or suspicious timing patterns were flagged for review.
  • Outlier scoring: Applied z-score and IQR-based outlier detection within each cluster segment to surface the most statistically anomalous individual outlets, reducing the review workload for the compliance team.

Flagged outlets were surfaced in a Power BI compliance dashboard with drill-through capability, enabling the trade marketing team to investigate specific accounts without needing to access the underlying Python pipeline.

Key Results

300K+
Retail outlets assessed by the pipeline
Reporting integrity significantly improved
Auto
Replaced manual audit sampling with automated detection

The compliance team was able to act on specific flagged accounts rather than conducting broad manual audits. Incentive payout accuracy improved and the resulting compliance data became more reliable as an input to field investment decisions.

Lessons Learned

  • Unsupervised methods require careful interpretation. Because there were no labelled examples of "non-compliant" behaviour, the output of the model was a ranked list of suspicious accounts rather than a definitive classification — setting the right expectations with stakeholders was critical.
  • Clustering is most useful when you have a meaningful basis for segmentation. Grouping by outlet type and region before applying K-Means produced much more coherent anomaly signals than running the algorithm across the entire dataset at once.
  • The dashboard was the product, not the model. Surfacing the results in Power BI with drill-through capability was what made the pipeline usable by the compliance team day-to-day.