# 080. Cross-category spending relationships

**Question:** Which spending categories show the strongest customer-level rank associations?

## Result

The largest computed metric is 0.8013 for grocery / detergents_paper; the smallest is -0.2072 for frozen / detergents_paper. Metric: spearman_rho (Spearman correlation).

Customer scale and channel can induce correlations across categories.

![Cross-category spending relationships](outputs/chart.png)

| pair | spearman_rho |
| --- | --- |
| grocery / detergents_paper | 0.8013 |
| milk / grocery | 0.773 |
| milk / detergents_paper | 0.68 |
| fresh / frozen | 0.3844 |
| milk / delicassen | 0.3728 |
| grocery / delicassen | 0.3043 |
| fresh / delicassen | 0.2384 |
| frozen / delicassen | 0.233 |
| detergents_paper / delicassen | 0.1833 |
| fresh / milk | -0.08392 |
| milk / frozen | -0.09297 |
| fresh / grocery | -0.12 |
| grocery / frozen | -0.1688 |
| fresh / detergents_paper | -0.1983 |

The chart shows 14 of 15 result rows; the table previews the first 14 in the analysis-defined order. [Download the full result table](outputs/results.csv). Numerical values are computed from the source; missing results stay unavailable.

## Method

Pairwise Spearman correlations across all six categories.

The study uses shared source preparation and reusable statistical routines. Its specific transformations are in [analysis.py](analysis.py), and common model/evaluation code is in [portfolio/methods.py](../../portfolio/methods.py). The [notebook](analysis.ipynb) executes the study and displays the saved results.

## Decision and limitations

Identify bundle hypotheses and test incremental response instead of assuming co-spend implies bundle demand.

Annual customer spending uses source monetary units, not an assumed currency. There are no margins, transactions or dates. Customer segments are descriptive and do not establish promotion response. 

Related studies may share observations or holdouts. These are focused analytical studies, not independent replications or deployed business systems. Any model refinements informed by these results need new untouched evaluation data. No commercial impact is inferred from an association or backtest.

## Reproduce

From the repository root, after installing `requirements.txt`:

```powershell
python projects/080-cross-category-spending-relationships/analysis.py
```

Source data are downloaded automatically if absent. Original archives are retained unchanged and checked by SHA-256. The cleaned cache normalizes column names; field-specific changes are visible in [data preparation](../../portfolio/data.py). Runtime evidence is in [receipt.json](outputs/receipt.json).

## Source

[Wholesale Customers](https://archive.ics.uci.edu/dataset/292/wholesale+customers), Cardoso (2013). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/wholesale.json) and [prepared-data audit](../../data/provenance/wholesale_prepared.json) record the downloaded files, field coverage and hashes.
