Spaces:
Build error
A newer version of the Streamlit SDK is available: 1.60.0
title: Predictive Maintenance System
emoji: π§
colorFrom: blue
colorTo: green
sdk: streamlit
sdk_version: 1.29.0
app_file: app.py
pinned: false
Predictive Maintenance System - AI4I 2020 Dataset
Project Overview
This project implements a comprehensive predictive maintenance system using machine learning to predict when industrial machinery needs maintenance. The system analyzes the AI4I 2020 Predictive Maintenance Dataset and provides interactive visualizations and real-time predictions through a Streamlit web application.
Features
- Comprehensive EDA: 15+ different exploratory data analyses
- Machine Learning Model: Random Forest Classifier for failure prediction
- Real-time Predictions: Interactive interface for runtime predictions
- Maintenance Scheduling: Estimates time to failure and maintenance urgency
- Interactive Visualizations: Dynamic charts and graphs using Plotly
- Batch Processing: Upload CSV files for batch predictions
Dataset
The AI4I 2020 Predictive Maintenance Dataset contains:
- 10,000 machine records
- 14 features including temperature, rotational speed, torque, and tool wear
- Binary target: Machine failure (0 = no failure, 1 = failure)
- 5 failure types: TWF, HDF, PWF, OSF, RNF
Project Structure
project/
βββ ai4i2020.csv # Dataset file
βββ analysis.py # EDA analysis script
βββ preprocessing.py # Data preprocessing module
βββ model.py # Machine learning model
βββ train_model.py # Script to train and save model
βββ app.py # Streamlit web application
βββ README.md # Project documentation
Installation
- Clone or download the project
- Install dependencies (requirements listed below):
pip install pandas==2.1.4 numpy==1.26.2 matplotlib==3.8.2 seaborn==0.13.0 scikit-learn==1.4.0 streamlit==1.29.0 plotly==5.18.0
- Ensure the dataset file (
ai4i2020.csv) is in the project directory
Usage
Option 1: Run Streamlit App Directly (Recommended)
The app will train the model automatically on first run:
streamlit run app.py
Option 2: Train Model First, Then Run App
- Train the model:
python train_model.py
- Run the Streamlit app:
streamlit run app.py
Option 3: Run EDA Analysis Only
python analysis.py
Streamlit Application
The web application includes four main sections:
1. Introduction
- Dataset overview and statistics
- Project goals and features
- Dataset preview
2. Exploratory Data Analysis
Interactive visualizations including:
- Summary statistics
- Target distribution
- Feature distributions
- Correlation analysis
- Failure analysis by machine type
- Tool wear analysis
- Temperature analysis
- Outlier detection
- Pairwise relationships
- Failure type breakdown
3. Model & Predictions
- Model performance metrics
- Feature importance visualization
- Runtime prediction: Enter machine parameters to predict maintenance needs
- Batch prediction: Upload CSV file for multiple predictions
- Maintenance urgency assessment
- Time-to-failure estimation
4. Conclusion
- Key findings and takeaways
- Applications and future improvements
EDA Analyses Performed
- Summary statistics (mean, median, mode, etc.)
- Missing value analysis
- Data types and unique value counts
- Target variable distribution
- Correlation analysis
- Outlier detection (IQR method)
- Feature distribution analysis
- Failure analysis by machine type
- Tool wear analysis
- Temperature analysis
- Power and rotational speed analysis
- Pairwise feature relationships
- Detailed failure type analysis
- Time to failure estimation
- Grouped aggregations
Machine Learning Model
Algorithm: Random Forest Classifier
Features: 11 engineered features including:
- Air temperature, Process temperature
- Rotational speed, Torque
- Tool wear
- Temperature difference
- Power
- Machine type encoding
Evaluation Metrics:
- Accuracy
- Precision
- Recall
- F1-Score
- ROC-AUC
Predictive Features
The model predicts:
- Machine Failure: Binary prediction (Yes/No)
- Failure Probability: Probability score (0-1)
- Time to Failure: Estimated minutes until maintenance needed
- Maintenance Status: Current maintenance requirement status
- Maintenance Urgency: CRITICAL, HIGH, MEDIUM, or LOW
Runtime Prediction
Users can input machine parameters:
- Machine Type (L, M, H)
- Air Temperature (K)
- Process Temperature (K)
- Rotational Speed (rpm)
- Torque (Nm)
- Tool Wear (minutes)
The system provides:
- Failure prediction
- Maintenance urgency level
- Estimated time to failure
- Detailed recommendations
Technical Stack
- Python 3.8+
- Data Processing: Pandas, NumPy
- Visualization: Matplotlib, Seaborn, Plotly
- Machine Learning: Scikit-learn
- Web Framework: Streamlit
Key Insights
- Tool wear is the most critical indicator of machine health
- Temperature difference between process and air temperature correlates with failures
- Machine type affects failure rates differently
- Early detection can prevent costly downtime
- Proactive maintenance scheduling can optimize operations
Applications
- Industrial manufacturing
- Equipment monitoring systems
- Preventive maintenance scheduling
- Cost reduction through failure prevention
- Production optimization
Future Enhancements
- Real-time data streaming integration
- IoT sensor integration
- Advanced ensemble methods
- Time-series analysis
- Automated alert system
- Historical maintenance record integration
Author
Developed as part of the Introduction to Data Science course project.
License
This project is for educational purposes.
Acknowledgments
- AI4I 2020 Predictive Maintenance Dataset
- Scikit-learn documentation
- Streamlit documentation
Note: Make sure the ai4i2020.csv file is in the same directory as the scripts before running the application.