# 083. Recorded fault class balance

**Question:** Which defect classes dominate the labeled inspection sample?

## Result

The largest computed metric is 0.3467 for Other_Faults; the smallest is 0.02834 for Dirtiness. Metric: sample_share (Share of labeled faults).

The denominator contains faulty observations only. This is not a defect rate across manufactured plates.

![Recorded fault class balance](outputs/chart.png)

| fault | records | sample_share |
| --- | --- | --- |
| Other_Faults | 673 | 0.3467 |
| Bumps | 402 | 0.2071 |
| K_Scatch | 391 | 0.2014 |
| Z_Scratch | 190 | 0.09789 |
| Pastry | 158 | 0.0814 |
| Stains | 72 | 0.03709 |
| Dirtiness | 55 | 0.02834 |

The chart shows 7 of 7 result rows; the table previews the first 7 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

Class counts and proportions across recorded faults.

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 class balance to choose metrics and inspect rare-class coverage before model fitting.

Every source row is a recorded fault. The data cannot estimate a production defect rate or distinguish healthy plates. Batch and machine IDs are absent, so grouped exact-input holdouts do not prove factory transfer. 

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/083-recorded-fault-class-balance/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

[Steel Plates Faults](https://archive.ics.uci.edu/dataset/198/steel+plates+faults), Buscema, Terzi and Tastle (2010). [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). Source data are transformed and aggregated in this study. [Source provenance](../../data/provenance/steel.json) and [prepared-data audit](../../data/provenance/steel_prepared.json) record the downloaded files, field coverage and hashes.
