# 006. Sales data cleaning sensitivity

**Question:** How do plausible cleaning choices alter gross invoiced sales?

## Result

The largest computed metric is 1.067e+07 for Retain source repeats; the smallest is 8.911e+06 for Known customers only. Metric: gross_gbp (GBP).

Unknown customers and repeated lines are different quality issues; neither is automatically an invalid sale.

![Sales data cleaning sensitivity](outputs/chart.png)

| policy | rows | gross_gbp | difference_from_retained_gbp |
| --- | --- | --- | --- |
| Retain source repeats | 530104 | 1.067e+07 | 0 |
| Remove exact repeats | 524878 | 1.064e+07 | -2.457e+04 |
| Known customers only | 397884 | 8.911e+06 | -1.755e+06 |

The chart shows 3 of 3 result rows; the table previews the first 3 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

Compare retained source rows, exact-row deduplication and exclusion of unidentified purchasers.

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

Choose cleaning rules from source-system evidence and document their financial effect.

Historical invoice lines; credits are not reliably matched to original sales. Gross purchases are not profit. Unidentified customers cannot support customer-level conclusions. Exact repeated lines remain unless the study explicitly compares removal. 

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/006-sales-data-cleaning-sensitivity/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

[Online Retail](https://archive.ics.uci.edu/dataset/352/online+retail), Chen (2015). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/retail.json) and [prepared-data audit](../../data/provenance/retail_prepared.json) record the downloaded files, field coverage and hashes.
