An AI-powered Predictive Maintenance System that predicts industrial machine failure using Machine Learning and real-time sensor data.
The system analyzes machine operating conditions and predicts whether the machine is healthy or has a possible failure risk. It helps industries perform preventive maintenance before unexpected breakdowns occur.
Industrial machines continuously generate sensor information such as temperature, speed, torque, and tool usage.
Unexpected machine failure can lead to:
- Production downtime
- Increased maintenance cost
- Reduced efficiency
This project applies Machine Learning techniques to predict machine failure conditions and provides maintenance recommendations through a web-based monitoring dashboard.
- Real-time machine failure prediction
- Industrial sensor monitoring dashboard
- Failure probability calculation
- AI-based maintenance recommendation
- Interactive slider control
- Manual sensor value input
- Light and Dark theme support
- Machine status monitoring
- FastAPI backend integration
Dataset:
AI4I 2020 Predictive Maintenance Dataset
Dataset Size:
Total Records : 10000
Normal Machine Records : 9661
Failure Records : 339
The machine learning model uses:
| Feature | Description |
|---|---|
| Air Temperature | Machine surrounding temperature |
| Process Temperature | Operating temperature |
| Rotational Speed | Machine RPM |
| Torque | Machine load |
| Tool Wear | Tool usage duration |
Dataset
↓
Data Cleaning
↓
Exploratory Data Analysis
↓
Feature Selection
↓
Train Test Split
↓
Model Training
↓
Model Comparison
↓
Best Model Selection
↓
Model Deployment
↓
FastAPI + React Integration
Performed preprocessing steps:
- Removed unnecessary columns
- Checked missing values
- Selected important sensor features
- Feature scaling using StandardScaler
- Stratified train-test splitting
The dataset contains imbalance:
Healthy Machines : 9661
Failure Machines : 339
Accuracy alone is not enough for this problem.
Methods analyzed:
- SMOTE Oversampling
- Class Weight Balancing
- Stratified Splitting
Final approach:
RandomForestClassifier(
class_weight="balanced"
)
Reason:
Class weight balancing improved failure detection without creating artificial synthetic failure records.
| Algorithm | Accuracy |
|---|---|
| Random Forest | 98.5% |
| XGBoost | 98.4% |
| Decision Tree | 97.8% |
| SVM | 97.2% |
| Logistic Regression | 96.85% |
Random Forest was selected because it achieved:
- High accuracy
- Better failure identification
- Good precision and recall balance
- Stable performance on sensor data
- Lower false predictions
Evaluation metrics used:
- Accuracy
- Precision
- Recall
- F1 Score
- Confusion Matrix
| Class | Precision | Recall | F1 Score | Support |
|---|---|---|---|---|
| Healthy Machine (0) | 0.99 | 1.00 | 0.99 | 1932 |
| Failure Machine (1) | 0.87 | 0.60 | 0.71 | 68 |
| Metric | Score |
|---|---|
| Accuracy | 98% |
| Macro Precision | 0.93 |
| Macro Recall | 0.80 |
| Macro F1 Score | 0.85 |
| Weighted Precision | 0.98 |
| Weighted Recall | 0.98 |
| Weighted F1 Score | 0.98 |
The confusion matrix shows the Random Forest model performance on machine failure prediction.
Explanation:
- Correct Healthy Predictions : 1926
- Correct Failure Predictions : 41
- False Failure Alerts : 6
- Missed Failure Cases : 27
React Dashboard
|
|
↓
FastAPI Backend
|
|
↓
Machine Learning Model
|
|
↓
Prediction Result
|
|
↓
Maintenance Recommendation
Backend Framework:
FastAPI
GET /machine
Returns:
- Machine ID
- Temperature
- RPM
- Torque
- Tool Wear
POST /predict
Returns:
{
Prediction Status,
Failure Probability,
Maintenance Recommendation
}
Developed using:
- React
- TypeScript
- Axios
- CSS
Dashboard includes:
- Sensor input panel
- Prediction result card
- Machine status table
- Theme switching
- Real-time API communication
- Python
- Pandas
- NumPy
- Scikit-Learn
- XGBoost
- Matplotlib
- Seaborn
- Joblib
- FastAPI
- Uvicorn
- Pydantic
- React
- TypeScript
- Axios
- CSS
AI-Predictive-Maintenance
│
├── backend
│
│ ├── main.py
│ ├── model.pkl
│ ├── scaler.pkl
│ └── requirements.txt
│
│
├── frontend
│
│ └── src
│
│ ├── App.tsx
│ └── App.css
│
│
├── ml
│
│ ├── dataset
│ └── model_training.ipynb
│
│
├── screenshots
│
│ └── dashboard.png
│
└── README.md
Move to backend folder:
cd backendInstall dependencies:
pip install -r requirements.txtRun server:
python -m uvicorn main:app --reloadServer:
http://127.0.0.1:8000
Move to frontend:
cd frontendInstall packages:
npm installStart React:
npm run devApplication:
http://localhost:5173
Machine Status:
Healthy Machine
Failure Probability:
4.62%
Recommendation:
Machine condition is normal.
Continue monitoring.
- IoT sensor integration
- Real-time industrial data streaming
- Cloud deployment
- Alert notification system
- Deep learning based prediction
The AI Predictive Maintenance System successfully predicts machine failure risks using industrial sensor data.
The integration of Machine Learning, FastAPI, and React provides a complete end-to-end intelligent monitoring solution for preventive maintenance.

