# 087. Multiclass fault recognition

**Question:** Can inspection features distinguish the seven recorded fault classes?

## Result

The largest computed metric is 0.7829 for Random forest; the smallest is 0.07239 for Prior baseline. Metric: macro_f1 (Macro F1).

Seven one-hot target indicators were removed during preparation. Healthy plates are not represented.

![Multiclass fault recognition](outputs/chart.png)

| model | accuracy | balanced_accuracy | macro_f1 |
| --- | --- | --- | --- |
| Prior baseline | 0.3393 | 0.1429 | 0.07239 |
| Logistic regression | 0.6787 | 0.6901 | 0.6842 |
| Random forest | 0.7455 | 0.7663 | 0.7829 |

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

Fixed multiclass classification with grouped identical inputs and macro-F1 evaluation.

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.

## Evaluation

Fixed 80/20 split of unique input groups (seed 42); exact input duplicates stay together. Training observations: 1,552; test observations: 389. Fixed models; default decision threshold; no holdout tuning.

Target: `fault`. Features: pixels_areas, x_perimeter, y_perimeter, minimum_of_luminosity, maximum_of_luminosity, length_of_conveyer, typeofsteel_a300, typeofsteel_a400, steel_plate_thickness, edges_index, empty_index, square_index, outside_x_index, edges_x_index, edges_y_index, outside_global_index, logofareas, log_x_index, log_y_index, orientation_index, luminosity_index, sigmoidofareas. Model results and row membership are recorded in [evaluation.json](outputs/evaluation.json).

## Decision and limitations

Validate against new production batches and healthy examples before considering deployment.

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/087-multiclass-fault-recognition/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.
