| --- |
| 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 |
|
|
| 1. **Clone or download the project** |
| 2. **Install dependencies** (requirements listed below): |
| ```bash |
| 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 |
| ``` |
| 3. **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: |
|
|
| ```bash |
| streamlit run app.py |
| ``` |
|
|
| ### Option 2: Train Model First, Then Run App |
|
|
| 1. **Train the model**: |
| ```bash |
| python train_model.py |
| ``` |
|
|
| 2. **Run the Streamlit app**: |
| ```bash |
| streamlit run app.py |
| ``` |
|
|
| ### Option 3: Run EDA Analysis Only |
|
|
| ```bash |
| 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 |
|
|
| 1. Summary statistics (mean, median, mode, etc.) |
| 2. Missing value analysis |
| 3. Data types and unique value counts |
| 4. Target variable distribution |
| 5. Correlation analysis |
| 6. Outlier detection (IQR method) |
| 7. Feature distribution analysis |
| 8. Failure analysis by machine type |
| 9. Tool wear analysis |
| 10. Temperature analysis |
| 11. Power and rotational speed analysis |
| 12. Pairwise feature relationships |
| 13. Detailed failure type analysis |
| 14. Time to failure estimation |
| 15. 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: |
| 1. **Machine Failure**: Binary prediction (Yes/No) |
| 2. **Failure Probability**: Probability score (0-1) |
| 3. **Time to Failure**: Estimated minutes until maintenance needed |
| 4. **Maintenance Status**: Current maintenance requirement status |
| 5. **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 |
|
|
| 1. **Tool wear** is the most critical indicator of machine health |
| 2. **Temperature difference** between process and air temperature correlates with failures |
| 3. Machine **type affects failure rates** differently |
| 4. Early detection can **prevent costly downtime** |
| 5. Proactive maintenance scheduling can **optimize operations** |
|
|
| ## Applications |
|
|
| - Industrial manufacturing |
| - Equipment monitoring systems |
| - Preventive maintenance scheduling |
| - Cost reduction through failure prevention |
| - Production optimization |
|
|
| ## Future Enhancements |
|
|
| 1. Real-time data streaming integration |
| 2. IoT sensor integration |
| 3. Advanced ensemble methods |
| 4. Time-series analysis |
| 5. Automated alert system |
| 6. 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. |