An end-to-end machine learning system that predicts imminent industrial equipment failures before they happen and diagnoses their failure type, based on live sensor readings — to prevent unplanned downtime and reduce maintenance costs.
| Problem | Unexpected equipment failures stop production lines and cost companies millions |
| Solution | A predictive model that determines when, which machine, and what type of failure — before it occurs |
- Binary Classification — Will the machine fail? (
Machine failure= 0/1) - Multi-class Classification — What failure type? (TWF / HDF / PWF / OSF / RNF + co-occurring failures)
The AI4I 2020 Predictive Maintenance Dataset — 10,000 records of an industrial milling machine with 5 sensors:
| Sensor | Unit |
|---|---|
| Air temperature | K |
| Process temperature | K |
| Rotational speed | rpm |
| Torque | Nm |
| Tool wear | min |
[Problem Framing] → [EDA] → [Feature Engineering] → [Modeling & Tuning] → [SHAP Interpretation] → [Packaging]
- Documented internal inconsistency in the original data between failure-type flags and the
Machine failurecolumn — reconciled with a clear policy. - Severe class imbalance (3.39% failures) — handled with
scale_pos_weight+ stratified cross-validation. - Tool wear is the leading driver of failures; product quality
Typeclearly affects failure rate. - Physics-based feature engineering derived from the known failure-generation rules:
Power,Temp Diff,Overstrain.
Three models compared fairly via 5-fold stratified cross-validation, then tuned with GridSearchCV:
| Model | Role |
|---|---|
| Random Forest | Baseline |
| XGBoost | Advanced (best) |
| LightGBM | Advanced alternative |
Chosen metric: Recall — because missing a real failure is far more costly than a false alarm in predictive maintenance.
| Metric | Value |
|---|---|
| Recall (failure detection) | 88.2% |
| Precision | 61.9% |
| F1-Score | 72.7% |
| Accuracy | 97.75% |
| ROC-AUC | 98.6% |
💡 Recall was deliberately prioritized over Precision: the cost of a missed failure (production downtime) vastly outweighs the cost of a false alarm (routine check).
SHAP confirms that Tool Wear, followed by rotational speed drop and power/overstrain, are the strongest signals the model captures — consistent with the real physics of the failures.
- ✅ Full CRISP-DM lifecycle (6 phases) in clean, documented Python.
- ✅ Physics-based feature engineering (Power, Temp Diff, Overstrain).
- ✅ Imbalanced-data handling (
scale_pos_weight) + stratified validation. - ✅ Hyperparameter tuning with
GridSearchCV. - ✅ Model interpretability with SHAP — engineer-friendly, not a black box.
- ✅ Production-ready packaging: modular
src/,config.py, saved.joblibmodel.
git clone <repo-url>
cd predictive-maintenance-engine
pip install -r requirements.txt
python src/train.py # train & save the model
python src/evaluate.py # evaluate the saved modelpredictive-maintenance-engine/
├── README.md
├── LICENSE
├── requirements.txt
├── config.py # central configuration
├── data/
│ └── ai4i2020.csv
├── assets/ # analysis figures
├── notebooks/ # five phase notebooks
├── models/ # saved model (.joblib)
└── src/
├── data_loader.py
├── features.py
├── preprocessing.py
├── train.py
└── evaluate.py
MIT License — see LICENSE.






