第3話Chapter 3

Shrinking the targets

A retail target-setting pipeline on SQL Server, where empirical Bayes shrinkage keeps small stores from getting wild targets.
  • SQL Server
  • Python
  • Empirical Bayes
  • ETL

2026

TevoDW, the retail data warehouse. Every store needs a sales target.
One noisy month and the target is nonsense.
Small stores, thin history, jumpy numbers.

Raw averages trust every store equally. They shouldn’t.

Borrow strength from the neighbours.
Shrink toward the group.
Three notebooks, all writing to SQL tables:
Targets: three-tier empirical Bayes (store, channel-category, global), Winsorized bounds, a TrustLevel column.
Significance: Mann-Whitney U with Benjamini-Hochberg correction.
Growth snapshot: CAGR, short-term momentum and SMPY.
Underneath: an ASR ETL with rolling 12-month logic, month-end detection and financial-week gap-filling in the date dimension.
Targets you can trust!
Every target carries a TrustLevel, so you can see how much history stands behind it.
Stats, in SQL.

Results land back in the warehouse, ready for reporting.