# 028. Alcohol and quality within wine type

**Question:** How does median sensory quality vary across declared alcohol bands within red and white samples?

## Result

The largest computed metric is 6.725 for white / (13, 20]; the smallest is 5.293 for red / (9, 10]. Metric: mean_quality (Sensory score).

Require at least 30 samples per band. Other chemical attributes differ between these groups.

![Alcohol and quality within wine type](outputs/chart.png)

| wine_type | alcohol_band | samples | median_quality | mean_quality | group |
| --- | --- | --- | --- | --- | --- |
| red | (0, 9] | 37 | 6 | 5.351 | red / (0, 9] |
| red | (10, 11] | 444 | 6 | 5.691 | red / (10, 11] |
| red | (11, 12] | 267 | 6 | 6.071 | red / (11, 12] |
| red | (12, 13] | 118 | 6 | 6.424 | red / (12, 13] |
| red | (9, 10] | 710 | 5 | 5.293 | red / (9, 10] |
| white | (0, 9] | 502 | 5 | 5.6 | white / (0, 9] |
| white | (10, 11] | 1252 | 6 | 5.864 | white / (10, 11] |
| white | (11, 12] | 850 | 6 | 6.191 | white / (11, 12] |
| white | (12, 13] | 609 | 7 | 6.571 | white / (12, 13] |
| white | (13, 20] | 102 | 7 | 6.725 | white / (13, 20] |
| white | (9, 10] | 1583 | 5 | 5.488 | white / (9, 10] |

The chart shows 11 of 11 result rows; the table previews the first 11 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

Stratified alcohol bands with sample counts and quality medians.

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

Use the stratified pattern to motivate a controlled laboratory study rather than a recipe claim.

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/028-alcohol-and-quality-within-wine-type/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.
