ahadalii/Predictive_Maintenance_System
0
1---2title: Predictive Maintenance System3emoji: ๐ง4colorFrom: blue5colorTo: green6sdk: streamlit7sdk_version: 1.29.08app_file: app.py9pinned: false10---11 12# Predictive Maintenance System - AI4I 2020 Dataset13 14## Project Overview15 16This 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.17 18## Features19 20- **Comprehensive EDA**: 15+ different exploratory data analyses21- **Machine Learning Model**: Random Forest Classifier for failure prediction22- **Real-time Predictions**: Interactive interface for runtime predictions23- **Maintenance Scheduling**: Estimates time to failure and maintenance urgency24- **Interactive Visualizations**: Dynamic charts and graphs using Plotly25- **Batch Processing**: Upload CSV files for batch predictions26 27## Dataset28 29The AI4I 2020 Predictive Maintenance Dataset contains:30- **10,000 machine records**31- **14 features** including temperature, rotational speed, torque, and tool wear32- **Binary target**: Machine failure (0 = no failure, 1 = failure)33- **5 failure types**: TWF, HDF, PWF, OSF, RNF34 35## Project Structure36 37```38project/39โโโ ai4i2020.csv # Dataset file40โโโ analysis.py # EDA analysis script41โโโ preprocessing.py # Data preprocessing module42โโโ model.py # Machine learning model43โโโ train_model.py # Script to train and save model44โโโ app.py # Streamlit web application45โโโ README.md # Project documentation46```47 48## Installation49 501. **Clone or download the project**512. **Install dependencies** (requirements listed below):52```bash53pip 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.054```553. **Ensure the dataset file (`ai4i2020.csv`) is in the project directory**56 57## Usage58 59### Option 1: Run Streamlit App Directly (Recommended)60 61The app will train the model automatically on first run:62 63```bash64streamlit run app.py65```66 67### Option 2: Train Model First, Then Run App68 691. **Train the model**:70```bash71python train_model.py72```73 742. **Run the Streamlit app**:75```bash76streamlit run app.py77```78 79### Option 3: Run EDA Analysis Only80 81```bash82python analysis.py83```84 85## Streamlit Application86 87The web application includes four main sections:88 89### 1. Introduction90- Dataset overview and statistics91- Project goals and features92- Dataset preview93 94### 2. Exploratory Data Analysis95Interactive visualizations including:96- Summary statistics97- Target distribution98- Feature distributions99- Correlation analysis100- Failure analysis by machine type101- Tool wear analysis102- Temperature analysis103- Outlier detection104- Pairwise relationships105- Failure type breakdown106 107### 3. Model & Predictions108- Model performance metrics109- Feature importance visualization110- **Runtime prediction**: Enter machine parameters to predict maintenance needs111- **Batch prediction**: Upload CSV file for multiple predictions112- Maintenance urgency assessment113- Time-to-failure estimation114 115### 4. Conclusion116- Key findings and takeaways117- Applications and future improvements118 119## EDA Analyses Performed120 1211. Summary statistics (mean, median, mode, etc.)1222. Missing value analysis1233. Data types and unique value counts1244. Target variable distribution1255. Correlation analysis1266. Outlier detection (IQR method)1277. Feature distribution analysis1288. Failure analysis by machine type1299. Tool wear analysis13010. Temperature analysis13111. Power and rotational speed analysis13212. Pairwise feature relationships13313. Detailed failure type analysis13414. Time to failure estimation13515. Grouped aggregations136 137## Machine Learning Model138 139- **Algorithm**: Random Forest Classifier140- **Features**: 11 engineered features including:141 - Air temperature, Process temperature142 - Rotational speed, Torque143 - Tool wear144 - Temperature difference145 - Power146 - Machine type encoding147 148- **Evaluation Metrics**:149 - Accuracy150 - Precision151 - Recall152 - F1-Score153 - ROC-AUC154 155## Predictive Features156 157The model predicts:1581. **Machine Failure**: Binary prediction (Yes/No)1592. **Failure Probability**: Probability score (0-1)1603. **Time to Failure**: Estimated minutes until maintenance needed1614. **Maintenance Status**: Current maintenance requirement status1625. **Maintenance Urgency**: CRITICAL, HIGH, MEDIUM, or LOW163 164## Runtime Prediction165 166Users can input machine parameters:167- Machine Type (L, M, H)168- Air Temperature (K)169- Process Temperature (K)170- Rotational Speed (rpm)171- Torque (Nm)172- Tool Wear (minutes)173 174The system provides:175- Failure prediction176- Maintenance urgency level177- Estimated time to failure178- Detailed recommendations179 180## Technical Stack181 182- **Python 3.8+**183- **Data Processing**: Pandas, NumPy184- **Visualization**: Matplotlib, Seaborn, Plotly185- **Machine Learning**: Scikit-learn186- **Web Framework**: Streamlit187 188## Key Insights189 1901. **Tool wear** is the most critical indicator of machine health1912. **Temperature difference** between process and air temperature correlates with failures1923. Machine **type affects failure rates** differently1934. Early detection can **prevent costly downtime**1945. Proactive maintenance scheduling can **optimize operations**195 196## Applications197 198- Industrial manufacturing199- Equipment monitoring systems200- Preventive maintenance scheduling201- Cost reduction through failure prevention202- Production optimization203 204## Future Enhancements205 2061. Real-time data streaming integration2072. IoT sensor integration2083. Advanced ensemble methods2094. Time-series analysis2105. Automated alert system2116. Historical maintenance record integration212 213## Author214 215Developed as part of the Introduction to Data Science course project.216 217## License218 219This project is for educational purposes.220 221## Acknowledgments222 223- AI4I 2020 Predictive Maintenance Dataset224- Scikit-learn documentation225- Streamlit documentation226 227---228 229**Note**: Make sure the `ai4i2020.csv` file is in the same directory as the scripts before running the application.