Skip to content

Anjali-550/tut2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Predictive Maintenance System

Machine Failure Prediction Using Industrial Sensor Data

Python Jupyter License


πŸ“Œ Overview

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

πŸ“Š Project Workflow

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.


🎯 Key Results

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):

  1. Torque [Nm] β€” 31.58%
  2. Rotational speed [rpm] β€” 29.31%
  3. Tool wear [min] β€” 20.06%
  4. Air temperature [K] β€” 9.93%
  5. Process temperature [K] β€” 7.00%

πŸ” Explainable AI

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

πŸ’‘ Key Insights

  1. The dataset is highly imbalanced, making PR-AUC a more informative metric than accuracy.
  2. Torque and Tool Wear are the most influential predictors of machine failure.
  3. Rotational Speed significantly contributes to failure prediction under certain operating conditions.
  4. Temperature variables provide supporting information but have comparatively lower predictive importance.
  5. Explainability confirms that multiple sensor interactions influence machine failure rather than any single feature.

Visualizations

PR Curve Comparison RF Feature Importances


πŸ“‚ Project Structure

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

πŸš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip or conda

Installation

# 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

Setup Data

# 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

Run the Analysis

# 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.ipynb

All outputs are saved to assets/ automatically.


πŸ“‹ Dataset Overview

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 failure flag

Failure Types

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

πŸ”§ Methodology

1. Data Cleaning & EDA (01_Data_Cleaning_EDA.ipynb)

  • βœ… 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)

2. Model Development (02_Predictive_Maintenance.ipynb)

  • 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

3. Interpretation & Insights (03_Model_Interpretation.ipynb)

  • SHAP feature importance analysis
  • Operating point selection (precision-recall trade-offs)
  • Business recommendations for maintenance scheduling
  • Model comparison and uplift quantification

Dependencies

See requirements.txt for full list:

  • Data: pandas, numpy
  • ML: scikit-learn
  • Visualization: matplotlib, seaborn
  • Interpretation: SHAP
pip install -r requirements.txt

🎯 Future Improvements

  1. Hyperparameter Optimization
  2. XGBoost and LightGBM Implementation
  3. Real-Time Prediction Dashboard
  4. Cloud Deployment
  5. Live Sensor Integration
  6. Automated Maintenance Alerts

Contributing

Contributions are welcome! For major changes:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/improvement)
  3. Commit your changes (git commit -m 'Add improvement')
  4. Push and open a pull request

License

This project is licensed under the MIT License β€” see the LICENSE file for details.


Contact & Questions

For questions or suggestions:

  • Open an Issue
  • Reach out via GitHub Discussions

References

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors