Spaces:
Sleeping
Sleeping
Sahil Garg commited on
Commit ·
92c73c1
1
Parent(s): caa411d
better output and metrices
Browse files- README.md +50 -13
- agent/prompts.yaml +43 -8
README.md
CHANGED
|
@@ -14,10 +14,12 @@ AI-powered predictive maintenance for solar PV inverters using ML models and LLM
|
|
| 14 |
|
| 15 |
## Features
|
| 16 |
|
| 17 |
-
- **Anomaly Detection**: Isolation Forest + LSTM Autoencoder
|
| 18 |
-
- **
|
| 19 |
-
- **
|
| 20 |
-
- **
|
|
|
|
|
|
|
| 21 |
|
| 22 |
## Quick Start
|
| 23 |
|
|
@@ -70,32 +72,67 @@ Analyzes sensor data and returns ML predictions with optional AI diagnosis.
|
|
| 70 |
{
|
| 71 |
"ml_output": {
|
| 72 |
"asset_id": "PV_INVERTER_001",
|
|
|
|
|
|
|
|
|
|
| 73 |
"failure_probability": 0.12,
|
| 74 |
"expected_ttf_days": 450.5,
|
| 75 |
"expected_rul_days": 9800.0,
|
|
|
|
|
|
|
| 76 |
"confidence": 0.85
|
| 77 |
},
|
| 78 |
"agent_output": {
|
| 79 |
-
"
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
}
|
| 84 |
}
|
| 85 |
```
|
| 86 |
|
| 87 |
### Data Processing Pipeline
|
| 88 |
|
| 89 |
-
1. **Input Validation**: Ensures voltage/current arrays match and contain sufficient data points
|
| 90 |
-
2. **Data Preparation**:
|
| 91 |
3. **Feature Engineering**: Creates 10 statistical features using rolling window analysis:
|
| 92 |
- Voltage mean/standard deviation
|
| 93 |
-
- Power mean/standard deviation
|
| 94 |
- Power delta and slope
|
| 95 |
- Normalized efficiency
|
| 96 |
- Temperature mean/standard deviation/delta
|
| 97 |
-
4. **ML Inference**:
|
| 98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
## Configuration
|
| 101 |
|
|
|
|
| 14 |
|
| 15 |
## Features
|
| 16 |
|
| 17 |
+
- **Advanced Anomaly Detection**: Isolation Forest + LSTM Autoencoder with reconstruction error analysis
|
| 18 |
+
- **Comprehensive Health Monitoring**: Real-time health scoring, anomaly detection, and trend analysis
|
| 19 |
+
- **Fault Classification**: Multi-class fault type prediction (Normal, Short Circuit, Degradation, Open Circuit, Shadowing)
|
| 20 |
+
- **Predictive Maintenance**: XGBoost models for time-to-failure, remaining useful life, and failure probability
|
| 21 |
+
- **AI Diagnosis**: Gemini LLM provides detailed maintenance recommendations with urgency levels
|
| 22 |
+
- **REST API**: FastAPI-based service with automatic documentation and validation
|
| 23 |
|
| 24 |
## Quick Start
|
| 25 |
|
|
|
|
| 72 |
{
|
| 73 |
"ml_output": {
|
| 74 |
"asset_id": "PV_INVERTER_001",
|
| 75 |
+
"health_score": 0.892,
|
| 76 |
+
"anomaly_score": 0.0342,
|
| 77 |
+
"health_trend_200step": -0.0123,
|
| 78 |
"failure_probability": 0.12,
|
| 79 |
"expected_ttf_days": 450.5,
|
| 80 |
"expected_rul_days": 9800.0,
|
| 81 |
+
"predicted_fault_type": "Normal",
|
| 82 |
+
"fault_confidence": 0.78,
|
| 83 |
"confidence": 0.85
|
| 84 |
},
|
| 85 |
"agent_output": {
|
| 86 |
+
"system_health": {
|
| 87 |
+
"status": "Good",
|
| 88 |
+
"health_score_explanation": "Health score of 0.892 indicates good system performance at 89% of optimal",
|
| 89 |
+
"anomaly_analysis": "Anomaly score of 0.0342 shows normal operation with minimal deviations",
|
| 90 |
+
"trend_assessment": "Slight negative trend (-0.0123) suggests gradual performance decline to monitor"
|
| 91 |
+
},
|
| 92 |
+
"failure_risk": {
|
| 93 |
+
"probability_assessment": "12% failure probability within 30 days represents low risk",
|
| 94 |
+
"time_to_failure_analysis": "450 days until predicted failure allows time for scheduled maintenance",
|
| 95 |
+
"remaining_life_summary": "9,800 days remaining useful life indicates good system longevity"
|
| 96 |
+
},
|
| 97 |
+
"fault_diagnosis": {
|
| 98 |
+
"primary_fault": "System classified as 'Normal' with 78% confidence, no major faults detected",
|
| 99 |
+
"confidence_interpretation": "85% overall confidence provides reliable analysis for decision making"
|
| 100 |
+
},
|
| 101 |
+
"maintenance_recommendations": {
|
| 102 |
+
"urgency_level": "Low",
|
| 103 |
+
"immediate_actions": [
|
| 104 |
+
"Continue routine performance monitoring",
|
| 105 |
+
"Schedule panel inspection within 3 months"
|
| 106 |
+
],
|
| 107 |
+
"monitoring_schedule": "Next comprehensive inspection in 90 days",
|
| 108 |
+
"preventive_measures": "Implement quarterly maintenance checks"
|
| 109 |
+
},
|
| 110 |
+
"key_insights": [
|
| 111 |
+
"System health is good but showing early degradation signs",
|
| 112 |
+
"No immediate action required, continue standard monitoring",
|
| 113 |
+
"Schedule maintenance before 450 days to prevent issues"
|
| 114 |
+
]
|
| 115 |
}
|
| 116 |
}
|
| 117 |
```
|
| 118 |
|
| 119 |
### Data Processing Pipeline
|
| 120 |
|
| 121 |
+
1. **Input Validation**: Ensures voltage/current/temperature arrays match and contain sufficient data points
|
| 122 |
+
2. **Data Preparation**: Filters active periods and downsamples for efficient processing
|
| 123 |
3. **Feature Engineering**: Creates 10 statistical features using rolling window analysis:
|
| 124 |
- Voltage mean/standard deviation
|
| 125 |
+
- Power mean/standard deviation
|
| 126 |
- Power delta and slope
|
| 127 |
- Normalized efficiency
|
| 128 |
- Temperature mean/standard deviation/delta
|
| 129 |
+
4. **ML Inference**:
|
| 130 |
+
- Anomaly detection via Isolation Forest + LSTM reconstruction error
|
| 131 |
+
- Health scoring and trend analysis
|
| 132 |
+
- Fault type classification (5 classes)
|
| 133 |
+
- Time-to-failure and remaining useful life prediction
|
| 134 |
+
- Failure probability calculation with weighted risk factors
|
| 135 |
+
5. **Agent Analysis**: LLM analyzes all ML metrics for comprehensive maintenance diagnosis (if API key provided)
|
| 136 |
|
| 137 |
## Configuration
|
| 138 |
|
agent/prompts.yaml
CHANGED
|
@@ -1,19 +1,54 @@
|
|
| 1 |
maintenance:
|
| 2 |
system: |
|
| 3 |
-
You are
|
| 4 |
-
|
| 5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
|
| 7 |
user_template: |
|
| 8 |
-
|
| 9 |
{phase2_output}
|
| 10 |
|
|
|
|
|
|
|
| 11 |
MANDATORY: Return output strictly in JSON format only. Do not include any markdown, code blocks, or extra text.
|
| 12 |
|
| 13 |
OUTPUT FORMAT:
|
| 14 |
{{
|
| 15 |
-
"
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
}}
|
|
|
|
| 1 |
maintenance:
|
| 2 |
system: |
|
| 3 |
+
You are an expert photovoltaic (PV) maintenance AI specializing in solar panel fault diagnosis and predictive maintenance.
|
| 4 |
+
|
| 5 |
+
PARAMETER MEANINGS:
|
| 6 |
+
- health_score: Current system health (0-1, higher = healthier)
|
| 7 |
+
- anomaly_score: LSTM reconstruction error (lower = more normal)
|
| 8 |
+
- health_trend_200step: Health change over last 200 data points (positive = improving, negative = degrading)
|
| 9 |
+
- failure_probability: Risk of failure in next 30 days (0-1, higher = higher risk)
|
| 10 |
+
- expected_ttf_days: Days until predicted failure
|
| 11 |
+
- expected_rul_days: Remaining useful life in days
|
| 12 |
+
- predicted_fault_type: Specific fault classification (Normal, Short Circuit, Degradation, Open Circuit, Shadowing)
|
| 13 |
+
- fault_confidence: Confidence in fault type prediction (0-1)
|
| 14 |
+
- confidence: Overall prediction confidence (0-1)
|
| 15 |
+
|
| 16 |
+
You must reason ONLY from the provided JSON data. Do NOT invent information.
|
| 17 |
|
| 18 |
user_template: |
|
| 19 |
+
ANALYZE THIS PV SYSTEM DATA FOR MAINTENANCE INSIGHTS:
|
| 20 |
{phase2_output}
|
| 21 |
|
| 22 |
+
Provide a concise maintenance analysis explaining what each parameter means for this PV system.
|
| 23 |
+
|
| 24 |
MANDATORY: Return output strictly in JSON format only. Do not include any markdown, code blocks, or extra text.
|
| 25 |
|
| 26 |
OUTPUT FORMAT:
|
| 27 |
{{
|
| 28 |
+
"system_health": {{
|
| 29 |
+
"status": "Excellent | Good | Fair | Poor | Critical",
|
| 30 |
+
"health_score_explanation": "Brief explanation of health_score meaning",
|
| 31 |
+
"anomaly_analysis": "Brief explanation of anomaly_score implications",
|
| 32 |
+
"trend_assessment": "Brief explanation of health_trend_200step significance"
|
| 33 |
+
}},
|
| 34 |
+
"failure_risk": {{
|
| 35 |
+
"probability_assessment": "Brief explanation of failure_probability meaning",
|
| 36 |
+
"time_to_failure_analysis": "Brief explanation of expected_ttf_days implications",
|
| 37 |
+
"remaining_life_summary": "Brief explanation of expected_rul_days significance"
|
| 38 |
+
}},
|
| 39 |
+
"fault_diagnosis": {{
|
| 40 |
+
"primary_fault": "Brief explanation of predicted_fault_type and fault_confidence",
|
| 41 |
+
"confidence_interpretation": "Brief explanation of overall confidence level"
|
| 42 |
+
}},
|
| 43 |
+
"maintenance_recommendations": {{
|
| 44 |
+
"urgency_level": "Low | Medium | High | Critical",
|
| 45 |
+
"immediate_actions": ["2 specific, actionable steps"],
|
| 46 |
+
"monitoring_schedule": "Recommended next check timing",
|
| 47 |
+
"preventive_measures": "One key long-term strategy"
|
| 48 |
+
}},
|
| 49 |
+
"key_insights": [
|
| 50 |
+
"Most important finding",
|
| 51 |
+
"Second key insight",
|
| 52 |
+
"Third insight with implication"
|
| 53 |
+
]
|
| 54 |
}}
|