Agentic RAG-Powered Predictive Maintenance Platform for Industrial Equipment
An end-to-end AI platform that combines XGBoost classifiers, FAISS semantic search, and LLM reasoning to predict equipment failures, estimate remaining useful life, and generate structured diagnostic reports — all through a real-time web dashboard.
Industrial maintenance is either reactive (waiting for failure) or preventative (replacing parts too early). This platform implements Agentic Predictive Maintenance using a 3-stage multi-agent pipeline:
Sensor Input (normalized 0-1)
│
▼
┌─────────────────────────────────────────┐
│ Stage 1: Routing Agent │
│ • Threshold anomaly detection │
│ • XGBoost fault classification │
│ • RUL regression (engine) │
│ • Health score (0-100) │
└──────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Stage 2: Retrieval Agent (RAG) │
│ • FAISS semantic search (1,527 chunks) │
│ • all-MiniLM-L6-v2 embeddings │
│ • Machine-type filtered results │
└──────────────┬──────────────────────────┘
│
▼
┌─────────────────────────────────────────┐
│ Stage 3: Reasoning Agent (LLM) │
│ • Context: sensors + ML + RAG chunks │
│ • Structured maintenance report │
│ • Root cause + urgency + actions │
└─────────────────────────────────────────┘
| Machine | Classifier | Features | Classes |
|---|---|---|---|
| CNC Machine | XGBoost + SMOTE + StandardScaler | Air temp, Process temp, RPM, Torque, Tool wear | Normal, Heat Dissipation, Overstrain, Power, Tool Wear Failure |
| Rotating Bearing | XGBoost + StandardScaler | Vibration (x/y), Temperature, RPM, Load, RMS, Kurtosis | Normal, Ball fault, Inner race, Outer race, Misalignment |
| Centrifugal Pump | XGBoost + StandardScaler | Flow rate, Pressure, Vibration, Temperature, Current, RPM | Normal, Seal leakage, Cavitation, Bearing wear, Impeller damage, Clogged filter |
| Turbofan Engine | XGBoost RUL Regressor | T2, T24, T30, P2, P30, Nf, Nc, Ps30, W31 | Remaining Useful Life (cycles) with severity bands |
predictive_intelligence_360/
├── agents/
│ ├── routing_agent.py # ML classification + anomaly detection + health scoring
│ ├── retrieval_agent.py # FAISS semantic search with machine-type filtering
│ └── reasoning_agent.py # LLM-powered diagnostic report generation
├── api/
│ └── main.py # FastAPI service (5 endpoints)
├── dashboard/
│ ├── server.js # Express proxy server (port 3000)
│ └── public/
│ ├── index.html # Single-page dashboard
│ ├── css/style.css # Dashboard styling
│ └── js/app.js # Frontend logic with real-time monitoring
├── models/
│ ├── train_classifier.py # XGBoost training pipeline (CNC/Bearing/Pump)
│ ├── train_rul_model.py # Engine RUL regressor training
│ └── saved/ # Persisted model artifacts (.joblib)
├── rag/
│ ├── vector_store.py # FAISS index builder + search
│ ├── embedding_pipeline.py # Sentence-transformer encoding
│ └── faiss_index/ # Persisted FAISS index + chunks
├── utils/
│ ├── config.py # Central configuration (features, thresholds, paths)
│ └── data_loader.py # Dataset loading utilities
├── run.py # CLI orchestrator (setup/serve/dashboard/predict)
├── system_test.py # Comprehensive test suite (112 tests)
├── requirements.txt # Python dependencies
└── .env # Environment config (API keys — gitignored)
file/ # RAG knowledge base (JSONL per machine type)
├── cnc_manufacturing_machine.jsonl
├── rotating_bearing.jsonl
├── turbofan_engine.jsonl
├── centrifugal_pump.jsonl
├── pdm_rag_final.jsonl # Combined knowledge base
└── synthetic_failures_ALL.jsonl
*.csv # Training datasets (root level)
├── ai4i2020_refined.csv # CNC (10,000 rows)
├── bearing_fault_refined.csv # Bearing (3,000 rows)
├── engine_rul_refined.csv # Turbofan (25,303 rows)
└── pump_sensor_refined.csv # Pump (5,000 rows)
- Python 3.10+
- Node.js 18+
cd predictive_intelligence_360
# Python
pip install -r requirements.txt
# Dashboard
cd dashboard && npm install && cd ..Create a .env file in predictive_intelligence_360/:
LLM_BASE_URL=https://openrouter.ai/api/v1
LLM_API_KEY=your-api-key-here
LLM_MODEL=meta-llama/llama-3.1-8b-instruct:freeThe platform works without an LLM key — the fast analysis mode uses ML-only predictions. The LLM is only needed for the full diagnostic report.
python run.py setupThis runs three steps:
- Trains XGBoost classifiers for CNC, Bearing, and Pump (with StandardScaler, SMOTE for CNC)
- Trains the Engine RUL regressor
- Builds the FAISS vector store from all JSONL knowledge files (1,527 chunks)
# Terminal 1: Start the API backend (port 8000)
python run.py serve
# Terminal 2: Start the dashboard (port 3000)
python run.py dashboardOpen http://localhost:3000 in your browser.
| Method | Endpoint | Description | Latency |
|---|---|---|---|
POST |
/predict |
Full 3-stage pipeline (ML + RAG + LLM) | 5–60s |
POST |
/predict/fast |
ML-only prediction (no RAG/LLM) | ~30ms |
POST |
/diagnose |
Alias for /predict |
5–60s |
GET |
/health |
Service health check | <5ms |
GET |
/stats |
Dataset statistics | <10ms |
All sensor values are normalized to 0–1:
POST /predict/fast
{
"machine_type": "cnc",
"sensor_data": {
"Air_temp_K": 0.50,
"Process_temp_K": 0.55,
"RPM": 0.50,
"Torque_Nm": 0.40,
"Tool_wear_min": 0.30
}
}{
"machine_type": "cnc",
"prediction": "Normal Operation",
"confidence": 0.999,
"health_score": 99,
"is_anomaly": false,
"anomaly_flags": [],
"rul": null,
"explanation": "**Machine:** CNC\n**Prediction:** Normal Operation\n...",
"analysis_mode": "fast",
"response_time_ms": 28
}- Real-time sensor gauges — visual display of all input sensors
- Health score trending — tracks health over multiple analyses
- Failure mode probability chart — shows all class probabilities
- Auto-monitor mode — periodic analysis at configurable intervals (5s–60s)
- Preset configurations — Normal, Warning, and Failure presets per machine type
- Analysis history — complete session log with risk levels
- AI diagnostic report — full LLM-generated maintenance report
- 4 machine types — CNC, Bearing, Pump, Engine switchable in the UI
Configurable per machine type (normalized 0–1 scale):
| Machine | Sensor | Condition | Threshold |
|---|---|---|---|
| CNC | Torque_Nm | High | > 0.70 |
| CNC | Tool_wear_min | High | > 0.80 |
| CNC | RPM | Low / High | < 0.15 / > 0.85 |
| Bearing | rms_vibration | High | > 0.50 |
| Bearing | kurtosis | High | > 0.50 |
| Bearing | temperature_C | High | > 0.70 |
| Engine | T30 | High | > 0.80 |
| Engine | P30 | Low | < 0.25 |
| Engine | Nf | Low | < 0.20 |
| Pump | vibration_mm_s | High | > 0.40 |
| Pump | flow_rate_lpm | Low | < 0.35 |
| Pump | temperature_C | High | > 0.60 |
After running python run.py setup, the following are saved in models/saved/:
| File | Description |
|---|---|
cnc_classifier.joblib |
XGBoost classifier (5 failure classes) |
cnc_scaler.joblib |
StandardScaler for CNC features |
cnc_type_encoder.joblib |
OneHotEncoder for machine grade (H/L/M) |
cnc_threshold_config.joblib |
Tool Wear Failure threshold (0.30) |
bearing_classifier.joblib |
XGBoost classifier (5 fault classes) |
bearing_scaler.joblib |
StandardScaler for bearing features |
pump_classifier.joblib |
XGBoost classifier (6 fault classes) |
pump_scaler.joblib |
StandardScaler for pump features |
engine_rul_regressor.joblib |
XGBoost regressor for RUL prediction |
| + label encoders, feature column lists | Per machine type |
The CNC classifier uses additional engineered features computed at both training and inference:
| Feature | Formula |
|---|---|
Torque_toolwear |
Torque_Nm × Tool_wear_min |
Torque_ratio |
Torque_Nm / RPM |
Power_estimate |
Torque_Nm × RPM |
Wear_per_cycle |
Tool_wear_min / Process_temp_K |
Stress_indicator |
(Torque_Nm × Tool_wear_min) / RPM |
Plus one-hot encoding of machine grade (H/L/M) and SMOTE oversampling for the rare Tool Wear Failure class.
cd predictive_intelligence_360
python system_test.pyThe test suite covers 8 sections with 112 tests:
| Section | Tests |
|---|---|
| ML Model Loading & Validation | 9 |
| Classifier Predictions | 6 |
| Feature Engineering Consistency | 16 |
| FAISS / RAG Vector Store | 14 |
| Agentic Pipeline End-to-End | 20 |
| Edge Cases & Robustness | 17 |
| API Validation | 9 |
| Performance Benchmarking | 3 |
| Code Quality & Security | 18 |
Latest results: 111 PASS, 0 FAIL, 1 WARN (advisory about .env API key)
.envwith API keys is gitignored- Model loading uses SHA-256 hash verification logging
- Pydantic input validation on all API endpoints
- Missing sensor features are filled with safe defaults (0.5) and logged
- LLM failures are caught with graceful fallback responses
| Layer | Technology |
|---|---|
| ML Models | XGBoost, scikit-learn, imbalanced-learn (SMOTE) |
| Vector Store | FAISS (IndexFlatIP, L2-normalized) |
| Embeddings | sentence-transformers (all-MiniLM-L6-v2, dim=384) |
| LLM | OpenRouter API (OpenAI-compatible, configurable model) |
| Backend API | FastAPI + Uvicorn (async) |
| Dashboard | Express.js + Vanilla JS SPA |
| Data | pandas, NumPy |
This project is for educational and demonstration purposes.