{
 "schema": "retail-segments-protocol/1",
 "question": "How much do the choice of features, scaling, distance and number of segments change who a team would contact, are the segments stable under resampling, and do they separate later ordering better than the recency-and-value rule?",
 "design": "DESIGN-segments.md",
 "decision_dates": {
  "primary": "2011-06-01",
  "replication": "2010-12-01"
 },
 "windows_days": {
  "features": 365,
  "outcome": 180,
  "quiet_gap": 90
 },
 "population": "active customers of the first part: positive net revenue and at least one sale in the 365 days before the date",
 "holdout": {
  "line_files": {
   "features": "lines before 2011-06-01",
   "outcome": "lines from 2011-06-01, opened only by the score stage"
  },
  "outcome": "ordered again (a product sale line) within 180 days from the date",
  "secondary_outcome": "log(1 + net revenue in the 180 days, negative counted as zero)"
 },
 "features": {
  "recency_days": "days since the last order",
  "frequency": "distinct orders with a product sale",
  "value": "past-year net revenue",
  "units_per_line": "mean units per sale line",
  "unit_price": "median unit price paid over sale lines",
  "breadth": "distinct product codes bought",
  "autumn_share": "share of gross sales bought in September to November"
 },
 "feature_sets": {
  "rv": [
   "recency_days",
   "value"
  ],
  "rfm": [
   "recency_days",
   "frequency",
   "value"
  ],
  "rfm_mix": [
   "recency_days",
   "frequency",
   "value",
   "units_per_line",
   "unit_price",
   "breadth",
   "autumn_share"
  ],
  "mix": [
   "units_per_line",
   "unit_price",
   "breadth",
   "autumn_share"
  ]
 },
 "scalings": {
  "standard": "log(1 + x) on every feature except autumn_share, then z-scores",
  "raw": "no change",
  "rank": "percentile rank of each feature (average ties)"
 },
 "algorithms": {
  "kmeans": {
   "distance": "squared Euclidean",
   "starts": 10,
   "scalings": [
    "standard",
    "raw",
    "rank"
   ]
  },
  "gmm": {
   "distance": "Mahalanobis per segment (full covariance)",
   "starts": 3,
   "scalings": [
    "standard"
   ]
  },
  "ward": {
   "distance": "Euclidean, Ward linkage",
   "scalings": [
    "standard"
   ],
   "assign": "nearest segment mean"
  },
  "average_manhattan": {
   "distance": "Manhattan, average linkage",
   "scalings": [
    "standard"
   ],
   "assign": "nearest segment median (Manhattan)"
  }
 },
 "k_range": [
  2,
  8
 ],
 "k_choice": "highest silhouette (Manhattan for average_manhattan, Euclidean otherwise), ties to the smaller k; mixture BIC reported, not used",
 "fit_seed": 17,
 "stability": {
  "date": "primary",
  "resamples": 100,
  "seed": 4111,
  "measure": "adjusted Rand index between full-data segments and each resample fit, over all customers; mean and 5th percentile",
  "second_measure": "share of customers in the Hungarian-matched segment in at least 90 of 100 resamples",
  "scaling": "fitted once on all customers, held fixed",
  "rule": "tier cut points set on each resample, 90-day gap fixed"
 },
 "usefulness": {
  "folds": 5,
  "fold_seed": 2903,
  "score": "segment share that ordered again, from the other folds",
  "primary": "out-of-fold AUC, ordered again within 180 days, all active customers",
  "secondary": [
   "the same AUC among quiet customers only",
   "out-of-fold R-squared of log(1 + next-period revenue) from segment means"
  ],
  "references": {
   "rule": "six cells: three value tiers x quiet or recent",
   "recency_alone": "customers ranked by days since the last order, nothing fitted",
   "logistic": "logistic regression (L2, C = 1) on rfm_mix with standard scaling, trained out of fold"
  },
  "interval": {
   "replicates": 1000,
   "seed": 6007,
   "method": "paired percentile bootstrap of AUC differences against the rule, scores held fixed"
  }
 },
 "winback_rule": "segments with median days since the last order over 90 and median past-year revenue at or above the median of all active customers; the list is every member",
 "study_bar": {
  "min_lost_revenue_share": 0.5,
  "max_share_of_quiet": 0.35
 },
 "worked_example": "on the primary date, the rule-list customer closest to the list median recency and value (sum of absolute percentile-rank differences within the list) among those whose win-back status under kmeans standard silhouette k differs between at least two feature sets; else the closest overall; ties by key",
 "public_suppression": "segments with fewer than 11 customers shown as fewer than 11, profile withheld",
 "scoring": "point estimates: held inside the band, missed outside, untestable when the measure cannot be computed",
 "predictions": [
  {
   "id": "P1",
   "text": "k-means on rfm (standard, silhouette k): AUC within 0.03 of the rule's",
   "measure": "auc[kmeans/standard/rfm@silk] - auc[rule]",
   "band": [
    -0.03,
    0.03
   ]
  },
  {
   "id": "P2",
   "text": "No configuration at its silhouette k has an AUC more than 0.03 above the rule's",
   "measure": "max over 24 configurations of auc[config@silk] - auc[rule]",
   "band": [
    null,
    0.03
   ]
  },
  {
   "id": "P3",
   "text": "The logistic regression beats the rule's AUC by at least 0.04 and every configuration at its silhouette k",
   "measure": "auc[logistic] - max(auc[rule], max over 24 configurations of auc[config@silk]) and auc[logistic] - auc[rule]",
   "band": [
    0.04,
    null
   ],
   "also": "auc[logistic] above every configuration at its silhouette k"
  },
  {
   "id": "P4",
   "text": "Recency alone reaches an AUC no more than 0.02 below the rule's",
   "measure": "auc[recency_alone] - auc[rule]",
   "band": [
    -0.02,
    null
   ]
  },
  {
   "id": "P5",
   "text": "Every mix configuration at its silhouette k has an AUC at least 0.05 below the rule's",
   "measure": "max over the 6 mix configurations of auc[config@silk] - auc[rule]",
   "band": [
    null,
    -0.05
   ]
  },
  {
   "id": "P6",
   "text": "k-means on rfm (standard): mean ARI at least 0.80 at k = 2, 3 and 4",
   "measure": "min over k in 2..4 of mean_ari[kmeans/standard/rfm@k]",
   "band": [
    0.8,
    null
   ]
  },
  {
   "id": "P7",
   "text": "k-means on rfm (standard): mean ARI at k = 8 at least 0.10 below k = 3",
   "measure": "mean_ari[@8] - mean_ari[@3]",
   "band": [
    null,
    -0.1
   ]
  },
  {
   "id": "P8",
   "text": "At k = 4 the Gaussian mixture has a lower mean ARI than k-means on each feature set",
   "measure": "max over sets of mean_ari[gmm/standard/set@4] - mean_ari[kmeans/standard/set@4]",
   "band": [
    null,
    0.0
   ],
   "strict": true
  },
  {
   "id": "P9",
   "text": "k-means on rfm with raw scaling puts at least 90% of customers in its largest segment at every k from 2 to 5",
   "measure": "min over k in 2..5 of largest segment share",
   "band": [
    0.9,
    null
   ]
  },
  {
   "id": "P10",
   "text": "Average linkage with Manhattan distance (standard) puts at least 90% of customers in its largest segment at k = 4 on each feature set",
   "measure": "min over sets of largest segment share at k = 4",
   "band": [
    0.9,
    null
   ]
  },
  {
   "id": "P11",
   "text": "The silhouette picks k = 2 or 3 in at least 12 of the 16 standard combinations",
   "measure": "count of standard combinations with silhouette k <= 3",
   "band": [
    12,
    null
   ]
  },
  {
   "id": "P12",
   "text": "The win-back list from k-means on rv (standard, silhouette k) overlaps the rule's list with a Jaccard of at least 0.4",
   "measure": "jaccard",
   "band": [
    0.4,
    null
   ]
  },
  {
   "id": "P13",
   "text": "The win-back list from k-means on mix (standard, silhouette k) overlaps the rule's list with a Jaccard of at most 0.2",
   "measure": "jaccard (untestable when no segment meets the win-back rule)",
   "band": [
    null,
    0.2
   ]
  },
  {
   "id": "P14",
   "text": "No standard configuration at its silhouette k yields a win-back list that meets the first part's bar",
   "measure": "count of the 16 standard lists meeting the bar",
   "band": [
    0,
    0
   ]
  },
  {
   "id": "P15",
   "text": "Replication, 1 December 2010: k-means on rfm (standard, silhouette k) has an AUC within 0.03 of the rule's",
   "measure": "auc difference at the replication date",
   "band": [
    -0.03,
    0.03
   ]
  }
 ],
 "changes": []
}
