Predict pass/fail outcomes in semiconductor manufacturing from high-dimensional sensor data using a Random Forest classifier, with an interactive sensor drift simulator powered by ipywidgets.
The SECOM dataset contains 1,567 samples with 591 sensor readings from a semiconductor manufacturing process. The goal is to predict whether a product will pass or fail quality checks. Challenges include high dimensionality, missing values, and extreme class imbalance (93:7 pass-to-fail).
| Property | Value |
|---|---|
| Source | UCI ML Repository |
| Instances | 1,567 |
| Features | 591 (sensor readings) |
| Task | Binary classification |
| Labels | -1 = Pass, 1 = Fail |
| Missing values | Yes |
Load Data → Drop columns with >50% NaN → Mean imputation → StandardScaler
→ Train/Test Split (75/25, stratified) → Random Forest (5,000 trees, class-weighted)
→ F2-threshold optimisation → Evaluate → Interactive drift simulation
Only 104 failures out of 1,567 samples (93:7 ratio). Standard accuracy is misleading — the model uses class_weight={0:4, 1:1} and F2-score optimisation to handle this imbalance.
| Rank | Sensor | Importance |
|---|---|---|
| 1 | Sensor_59 | 0.0806 |
| 2 | Sensor_341 | 0.0167 |
| 3 | Sensor_103 | 0.0158 |
| 4 | Sensor_16 | 0.0127 |
| 5 | Sensor_477 | 0.0115 |
| 6 | Sensor_64 | 0.0109 |
| 7 | Sensor_582 | 0.0098 |
| 8 | Sensor_0 | 0.0094 |
| 9 | Sensor_205 | 0.0094 |
| 10 | Sensor_348 | 0.0089 |
Sensor_59 is the dominant predictor with an importance score nearly 5× higher than the second-ranked sensor.
Sensor_59 distribution: failures (red) show a broader range and higher values than passes (blue)
Sensor_59 boxplot: clearest inter-class separation of all sensors (median ~+10 fail vs ~0 pass)
Sensor_103 shows a clear downward trend over the first ~800 samples (equipment wear-in), stabilising afterward. Monitoring such drift is critical for production deployment.
Optimal F2 threshold: 0.0975 — the model catches 77% of failures (recall) at the cost of low precision (19%). This trade-off is appropriate for manufacturing QC where missing a failure is far costlier than a false alarm.
The notebook's final cell provides an ipywidgets dashboard that lets you:
- Select any subset of the top 10 important sensors via checkboxes
- Apply a percentage shift (-100% to +100%) via a slider
- Recompute risk levels (Low / Medium / High) based on percentiles
- Visualise the before/after risk distribution as a grouped bar chart
This demonstrates how small sensor deviations disproportionately impact predicted risk at scale.
numpy pandas matplotlib seaborn scikit-learn ipywidgets IPython
| File | Description |
|---|---|
SECOM.ipynb |
Full notebook with pipeline, visualisations, and interactive simulation |
secom.data |
Sensor data (590 columns, space-separated) |
secom_labels.data |
Labels (-1 pass, 1 fail) |
secom.names |
Dataset description (UCI format) |
images/ |
Extracted notebook visualisations |
- Sensor_59 dominates — 5× the importance of any other sensor; should be under continuous surveillance in production.
- F2 optimisation is essential — catches 77% of failures despite 93:7 imbalance by weighting recall over precision.
- Sensor redundancy — correlated pairs (477↔205, 59↔341) can be consolidated.
- Temporal drift — Sensor_103 shows clear wear-in behaviour; retraining or drift compensation is needed over time.
- Small drifts compound — even modest sensor drift shifts risk profiles significantly at scale.


