This project presents an end-to-end Predictive Maintenance System developed using the AI4I 2020 Predictive Maintenance Dataset. The objective is to predict machine failures before they occur by analyzing sensor data collected during machine operation.
The project follows a complete data science workflow including data cleaning, exploratory data analysis (EDA), feature engineering, machine learning model development, evaluation, and explainable AI using SHAP.
The final model enables maintenance teams to identify high-risk machines early, helping reduce unexpected downtime and optimize maintenance schedules.
π― Problem Statement
Unexpected machine failures can lead to production downtime, increased maintenance costs, and operational inefficiencies.
The objective of this project is to build a machine learning model capable of accurately predicting machine failures based on operational sensor data while providing interpretable explanations for each prediction.
Business Impact:
- π― 35.29% failure detection rate at 90% precision (Random Forest)
- π΄ Reduces false alarms by 22.35 percentage points vs. baseline
- βοΈ Enables proactive maintenance planning instead of reactive repairs
This project is organized into 3 modular notebooks for reproducibility and clarity:
| # | Notebook | Purpose |
|---|---|---|
| 1 | 01_Data_Cleaning_EDA.ipynb |
Data loading, quality checks, exploratory analysis, leakage detection |
| 2 | 02_Predictive_Maintenance.ipynb |
Feature engineering, train/test split, model training & evaluation |
| 3 | 03_Model_Interpretation.ipynb |
Feature importance, SHAP analysis, business operating points |
Each notebook is self-contained and can be run independently.
| Model | PR-AUC | ROC-AUC | Recall @ 90% Precision | Threshold |
|---|---|---|---|---|
| Random Forest | 0.7609 | 0.9664 | 35.29% | 0.58 |
| Calibrated Logistic | 0.3793 | 0.8833 | 12.94% | 0.6475 |
Top 5 Most Important Features (Random Forest):
- Torque [Nm] β 31.58%
- Rotational speed [rpm] β 29.31%
- Tool wear [min] β 20.06%
- Air temperature [K] β 9.93%
- Process temperature [K] β 7.00%
To improve transparency, SHAP (SHapley Additive Explanations) was used to interpret model predictions.
The explainability notebook includes:
SHAP Summary Plot SHAP Feature Importance SHAP Waterfall Plot SHAP Force Plot Global Model Interpretation Local Prediction Explanations
- The dataset is highly imbalanced, making PR-AUC a more informative metric than accuracy.
- Torque and Tool Wear are the most influential predictors of machine failure.
- Rotational Speed significantly contributes to failure prediction under certain operating conditions.
- Temperature variables provide supporting information but have comparatively lower predictive importance.
- Explainability confirms that multiple sensor interactions influence machine failure rather than any single feature.
predictive-maintenance-model/
βββ notebook/
β βββ 01_Data_Cleaning_EDA.ipynb
β βββ 02_Predictive_Maintenance.ipynb
β βββ 03_Model_Interpretation.ipynb
βββ data/
β βββ ai4i2020.csv # Raw data (download from UCI ML)
β βββ ai4i2020_clean.csv
βββ models/
β βββ random_forest_model.pkl
β βββ logistic_model.pkl
βββ assets/
β βββ pr_curve_comparison.png
β βββ feature_importances_rf.png
β βββ metrics_summary.csv
β βββ operating_point_uplift.csv
βββ requirements.txt
βββ .gitignore
βββ README.md
- Python 3.8+
- pip or conda
# Clone the repository
git clone https://github.com/okayprashant/predictive-maintenance-model.git
cd predictive-maintenance-model
# (Optional) Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt# Download dataset
# Visit: https://archive.ics.uci.edu/ml/datasets/AI4I+2020+Predictive+Maintenance+Dataset
# Download ai4i2020.csv and place it in the data/ folder
mkdir -p data
# Place ai4i2020.csv here# Start Jupyter
jupyter notebook
# Open and run notebooks in order:
# 1. notebook/01_Data_Cleaning_EDA.ipynb
# 2. notebook/02_Predictive_Maintenance.ipynb
# 3. notebook/03_Model_Interpretation.ipynbAll outputs are saved to assets/ automatically.
Source: UCI Machine Learning Repository β AI4I 2020 Predictive Maintenance Dataset
- Rows: ~10,000 machine operations
- Columns: 14 features (operational parameters + maintenance flags)
- Target: Binary
Machine failureflag
| Code | Type | Description |
|---|---|---|
| TWF | Tool Wear Failure | Excessive tool wear |
| HDF | Heat Dissipation | Overheating/poor cooling |
| PWF | Power Failure | Electrical/power system |
| OSF | Overstrain Failure | Mechanical stress |
| RNF | Random Failure | Unclassified events |
- β Quality checks and missing value handling
- β Label consistency verification (failure subtypes vs. target)
- β Class imbalance analysis
- β Feature distributions and correlations
- β Leakage detection (subtype flags removed before modeling)
- Feature Engineering: Extract product category, handle categorical variables
- Preprocessing: Stratified train/test split, standardization, one-hot encoding
- Models Trained:
- Random Forest (non-linear, strong baseline)
- Calibrated Logistic Regression (interpretable, probability-calibrated)
- Evaluation: PR-AUC, ROC-AUC, Recall @ Fixed Precision
- SHAP feature importance analysis
- Operating point selection (precision-recall trade-offs)
- Business recommendations for maintenance scheduling
- Model comparison and uplift quantification
See requirements.txt for full list:
- Data: pandas, numpy
- ML: scikit-learn
- Visualization: matplotlib, seaborn
- Interpretation: SHAP
pip install -r requirements.txt- Hyperparameter Optimization
- XGBoost and LightGBM Implementation
- Real-Time Prediction Dashboard
- Cloud Deployment
- Live Sensor Integration
- Automated Maintenance Alerts
Contributions are welcome! For major changes:
- Fork the repository
- Create a feature branch (
git checkout -b feature/improvement) - Commit your changes (
git commit -m 'Add improvement') - Push and open a pull request
This project is licensed under the MIT License β see the LICENSE file for details.
For questions or suggestions:
- Open an Issue
- Reach out via GitHub Discussions
- Dataset: AI4I 2020 Predictive Maintenance Dataset (UCI ML)
- Paper: Matzka, S. (2020). Explainable Artificial Intelligence for Predictive Maintenance Applications, 2020.
- SHAP: SHapley Additive exPlanations

