Proactive equipment maintenance through intelligent Time-To-Failure predictions
Demo โข Installation โข Usage โข API Reference โข Contributing
Predictive Maintenance is a cutting-edge machine learning solution that transforms traditional reactive maintenance into a proactive, data-driven approach. Our system leverages advanced XGBoost Multi-Output Regression to predict equipment failures before they occur, potentially saving thousands in downtime costs.
- Multi-Component Prediction: Simultaneously predicts failure times for 4 different machine components
- Short-Term Accuracy: Optimized for predictions under 10 weeks with ~91% accuracy
- Real-Time Interface: Flask-based web application for instant predictions
- Industrial Ready: Designed for real-world manufacturing environments
- Comprehensive Pipeline: End-to-end solution from data preprocessing to deployment
| Metric | Value |
|---|---|
| Test Rยฒ | ~0.95 |
| Test MAPE | ~11.25% |
| Short-Term MAE | ~0.91 weeks |
| Training Samples | 200,000 (stratified) |
predictive-maintenance/
โโโ ๐ model_code/
โ โโโ ๐ Model_XGB.py # Main training pipeline
โ โโโ ๐ฎ manual.py # Manual prediction script
โ
โโโ ๐ flask_code/
โ โโโ ๐ app.py # Flask backend server
โ โโโ ๐ templates/
โ โโโ ๐จ index.html # Web interface
โ
โโโ ๐ TTF_Dataset_Weeks.csv # Training dataset
โโโ ๐ requirements.txt # Python dependencies
โโโ ๐ README.md # Project documentation
โโโ ๐ฏ .gitignore # Git ignore rules
- Python 3.8 or higher
- pip package manager
- Git
-
Clone the Repository
git clone https://github.com/yourusername/predictive-maintenance.git cd predictive-maintenance -
Create Virtual Environment (Recommended)
# Windows python -m venv venv venv\Scripts\activate # macOS/Linux python3 -m venv venv source venv/bin/activate
-
Install Dependencies
pip install -r requirements.txt
Or install manually:
pip install xgboost pandas scikit-learn flask matplotlib seaborn joblib numpy
cd model_code
python Model_XGB.pyOutput: Trained model files (model.pkl, scaler.pkl, encoders.pkl)
python manual.pyProvide machine parameters and get TTF predictions for all components.
cd flask_code
python app.py๐ Access: Open your browser to http://127.0.0.1:5000
Features:
- Upload machine data via web interface
- Real-time TTF predictions
- Visual results display
- Export predictions as CSV
| Category | Features |
|---|---|
| Sensor Data | volt, rotate, pressure, vibration |
| Machine Info | model, age, error_count |
| Maintenance | days_since_comp1_maint to days_since_comp4_maint |
ttf_comp1_weeks- Time to failure for Component 1ttf_comp2_weeks- Time to failure for Component 2ttf_comp3_weeks- Time to failure for Component 3ttf_comp4_weeks- Time to failure for Component 4
- Stratified Sampling: 200,000 representative samples
- Feature Scaling: StandardScaler normalization
- Encoding: Label encoding for categorical variables
- Quality Assurance: Outlier detection and handling
graph LR
A[Raw Data] --> B[Preprocessing]
B --> C[Feature Engineering]
C --> D[XGBoost Multi-Output]
D --> E[TTF Predictions]
E --> F[Maintenance Scheduling]
-
Data Preprocessing
- Stratified sampling for balanced representation
- Feature scaling and encoding
- Missing value imputation
-
Model Architecture
- XGBoostRegressor with MultiOutputRegressor wrapper
- Custom hyperparameter tuning
- Cross-validation for robust performance
-
Evaluation Strategy
- Multiple metrics: RMSE, MAE, Rยฒ, MAPE
- Special focus on short-term predictions (<10 weeks)
- Component-wise performance analysis
Component 1: Rยฒ = 0.94, MAPE = 10.8%
Component 2: Rยฒ = 0.95, MAPE = 11.2%
Component 3: Rยฒ = 0.96, MAPE = 11.5%
Component 4: Rยฒ = 0.95, MAPE = 11.4%
- Mean Absolute Error: 0.91 weeks
- Critical for: Emergency maintenance scheduling
- Business Impact: Prevents unexpected downdowns
Predict TTF for machine components.
Request Body:
{
"volt": 180.5,
"rotate": 1200,
"pressure": 85.2,
"vibration": 45.1,
"model": "Model_A",
"age": 156,
"error_count": 3,
"days_since_comp1_maint": 45,
"days_since_comp2_maint": 32,
"days_since_comp3_maint": 67,
"days_since_comp4_maint": 23
}Response:
{
"predictions": {
"component_1": 8.5,
"component_2": 12.3,
"component_3": 6.1,
"component_4": 15.7
},
"status": "success",
"timestamp": "2024-01-20T10:30:00Z"
}The model considers these factors in order of importance:
- Vibration levels - Primary indicator of component stress
- Days since last maintenance - Critical for all components
- Machine age - Long-term degradation factor
- Error count - Operational stress indicator
- Sensor readings - Real-time operational state
๐ง Coming Soon: SHAP-based feature importance and prediction explanations
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "flask_code/app.py"]- Scalability: Consider using Gunicorn for production
- Monitoring: Implement logging and performance monitoring
- Security: Add authentication and input validation
- Data Pipeline: Automate model retraining with new data
- XGBoost multi-output model
- Flask web interface
- Basic performance metrics
We welcome contributions! Please see our Contributing Guidelines for details.
This project is licensed under the MIT License - see the LICENSE file for details.
| Dharam Patel | Ayesha Patel | Vrunda Radadiya |
โญ Star this repository if it helped you!