# 036. Unsupervised chemistry profiles

**Question:** Do chemistry-based clusters differ in their sensory-score distributions?

## Result

The largest computed metric is 6.113 for 3.0; the smallest is 5.399 for 0.0. Metric: mean_quality (Sensory score).

Exploratory silhouette=0.229; K=4 was fixed before fitting. Clusters may mainly reflect wine type.

![Unsupervised chemistry profiles](outputs/chart.png)

| cluster | samples | mean_quality | higher_rated_share | red_share |
| --- | --- | --- | --- | --- |
| 0 | 966 | 5.399 | 0.05694 | 0.9193 |
| 1 | 2138 | 5.632 | 0.1034 | 0.008419 |
| 2 | 707 | 5.836 | 0.2207 | 0.9349 |
| 3 | 2686 | 6.113 | 0.3146 | 0.01191 |

The chart shows 4 of 4 result rows; the table previews the first 4 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

Four K-means groups on standardized log chemical measurements; sensory labels excluded during fitting.

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

Inspect chemical profiles without assigning quality meanings to cluster numbers.

Sensory scores are ordinal and concentrated in the middle. Producer and batch IDs are unavailable. Associations are not recipes for changing quality or evidence of market price. 

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/036-unsupervised-chemistry-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

[Wine Quality](https://archive.ics.uci.edu/dataset/186/wine+quality), Cortez et al. (2009). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/wine.json) and [prepared-data audit](../../data/provenance/wine_prepared.json) record the downloaded files, field coverage and hashes.
