# 082. Atypical wholesale purchasing profiles

**Question:** Which customer spending profiles are unusual relative to this sample?

## Result

The largest computed metric is 0.7205 for 154.0; the smallest is 0.3702 for 147.0. Metric: review_score (Relative anomaly score).

There are no anomaly labels. The review fraction is a workflow assumption, not a measured error rate.

![Atypical wholesale purchasing profiles](outputs/chart.png)

| row_id | fresh | milk | grocery | frozen | detergents_paper | delicassen | review_score |
| --- | --- | --- | --- | --- | --- | --- | --- |
| 154 | 622 | 55 | 137 | 75 | 7 | 8 | 0.7205 |
| 338 | 3 | 333 | 7021 | 15601 | 15 | 550 | 0.6651 |
| 65 | 85 | 20959 | 45828 | 36 | 24231 | 1423 | 0.6293 |
| 75 | 20398 | 1137 | 3 | 4407 | 3 | 975 | 0.6276 |
| 183 | 36847 | 43950 | 20170 | 36534 | 239 | 47943 | 0.6166 |
| 161 | 12434 | 540 | 283 | 1092 | 3 | 2233 | 0.613 |
| 142 | 37036 | 7152 | 8253 | 2995 | 20 | 3 | 0.6106 |
| 47 | 44466 | 54259 | 55571 | 7782 | 24171 | 6465 | 0.6087 |
| 356 | 22686 | 134 | 218 | 3157 | 9 | 548 | 0.6051 |
| 128 | 140 | 8847 | 3823 | 142 | 1062 | 3 | 0.599 |
| 85 | 16117 | 46197 | 92780 | 1026 | 40827 | 2944 | 0.5988 |
| 289 | 42786 | 286 | 471 | 1388 | 32 | 22 | 0.5986 |
| 66 | 9 | 1534 | 7417 | 175 | 3468 | 27 | 0.5853 |
| 357 | 37 | 1275 | 22272 | 137 | 6747 | 110 | 0.5814 |

The chart shows 14 of 440 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

Isolation Forest on log-transformed standardized category spending, with a declared 5% review fraction.

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

Review atypical profiles for data quality or legitimate specialized purchasing; do not label them fraudulent.

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/082-atypical-wholesale-purchasing-profiles/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.
