Spaces:
Sleeping
Sleeping
Commit
·
d26852c
0
Parent(s):
Initial commit: Predictive Agent - LSTM-Based RUL Prediction
Browse files- README.md +41 -0
- app.py +384 -0
- demo_docs/turbine_unit3_degrading.csv +41 -0
- demo_docs/turbine_unit7_stable.csv +31 -0
- requirements.txt +4 -0
README.md
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Predictive Agent
|
| 3 |
+
emoji: 🔧
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 5.9.1
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
| 11 |
+
short_description: LSTM-Based RUL Prediction
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
# Predictive Agent | LSTM-Based RUL Prediction
|
| 15 |
+
|
| 16 |
+
RUL prediction system extending turbine life 15-20% using LSTM neural networks trained on NASA C-MAPSS and GE 7FA patterns.
|
| 17 |
+
|
| 18 |
+
## Demo
|
| 19 |
+
|
| 20 |
+
Click **"Run Analysis"** to see the model predict Remaining Useful Life and generate maintenance recommendations.
|
| 21 |
+
|
| 22 |
+
## Features
|
| 23 |
+
|
| 24 |
+
- **Pre-loaded Demo**: Click to analyze degrading vs healthy turbine scenarios
|
| 25 |
+
- **Upload Your Data**: Test with your own asset health CSV files
|
| 26 |
+
- **Maintenance Strategy**: Automated recommendations based on RUL prediction
|
| 27 |
+
|
| 28 |
+
## Technical Details
|
| 29 |
+
|
| 30 |
+
| Component | Details |
|
| 31 |
+
|-----------|---------|
|
| 32 |
+
| **Model** | LSTM Neural Network (2 layers, 64→32 units) |
|
| 33 |
+
| **Training Data** | NASA C-MAPSS + GE Frame 7FA patterns |
|
| 34 |
+
| **Dataset** | [ccgt-health-history](https://huggingface.co/datasets/davidfertube/ccgt-health-history) |
|
| 35 |
+
| **Output** | RUL (cycles) + Maintenance Strategy |
|
| 36 |
+
|
| 37 |
+
## Links
|
| 38 |
+
|
| 39 |
+
- **Portfolio**: [davidfernandez.dev](https://davidfernandez.dev)
|
| 40 |
+
- **GitHub**: [predictive-agent](https://github.com/davidfertube/predictive-agent)
|
| 41 |
+
- **Model**: [rul-predictor-ccgt](https://huggingface.co/davidfertube/rul-predictor-ccgt)
|
app.py
ADDED
|
@@ -0,0 +1,384 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import numpy as np
|
| 4 |
+
import plotly.graph_objects as go
|
| 5 |
+
from io import StringIO
|
| 6 |
+
|
| 7 |
+
# ============================================
|
| 8 |
+
# PRE-LOADED DEMO DATA - GE 7FA Turbine Degradation
|
| 9 |
+
# ============================================
|
| 10 |
+
DEMO_DATA_DEGRADING = """cycle,health_index,vibration,heat_rate_delta,operating_hours,start_count
|
| 11 |
+
1,98.2,0.18,0.5,1000,45
|
| 12 |
+
2,97.8,0.19,0.6,1024,45
|
| 13 |
+
3,97.5,0.18,0.7,1048,46
|
| 14 |
+
4,97.1,0.20,0.8,1072,46
|
| 15 |
+
5,96.8,0.19,0.9,1096,47
|
| 16 |
+
6,96.4,0.21,1.0,1120,47
|
| 17 |
+
7,96.0,0.20,1.1,1144,48
|
| 18 |
+
8,95.6,0.22,1.2,1168,48
|
| 19 |
+
9,95.2,0.21,1.3,1192,49
|
| 20 |
+
10,94.8,0.23,1.4,1216,49
|
| 21 |
+
11,94.3,0.22,1.5,1240,50
|
| 22 |
+
12,93.9,0.24,1.6,1264,50
|
| 23 |
+
13,93.4,0.23,1.8,1288,51
|
| 24 |
+
14,92.9,0.25,1.9,1312,51
|
| 25 |
+
15,92.4,0.24,2.0,1336,52
|
| 26 |
+
16,91.9,0.26,2.2,1360,52
|
| 27 |
+
17,91.3,0.25,2.3,1384,53
|
| 28 |
+
18,90.8,0.27,2.5,1408,53
|
| 29 |
+
19,90.2,0.26,2.6,1432,54
|
| 30 |
+
20,89.6,0.28,2.8,1456,54
|
| 31 |
+
21,89.0,0.27,3.0,1480,55
|
| 32 |
+
22,88.4,0.29,3.1,1504,55
|
| 33 |
+
23,87.7,0.28,3.3,1528,56
|
| 34 |
+
24,87.0,0.30,3.5,1552,56
|
| 35 |
+
25,86.3,0.29,3.7,1576,57
|
| 36 |
+
26,85.6,0.31,3.9,1600,57
|
| 37 |
+
27,84.8,0.30,4.1,1624,58
|
| 38 |
+
28,84.0,0.32,4.3,1648,58
|
| 39 |
+
29,83.2,0.31,4.5,1672,59
|
| 40 |
+
30,82.3,0.33,4.7,1696,59
|
| 41 |
+
31,81.4,0.32,5.0,1720,60
|
| 42 |
+
32,80.5,0.34,5.2,1744,60
|
| 43 |
+
33,79.5,0.33,5.5,1768,61
|
| 44 |
+
34,78.5,0.35,5.7,1792,61
|
| 45 |
+
35,77.5,0.34,6.0,1816,62
|
| 46 |
+
36,76.4,0.36,6.3,1840,62
|
| 47 |
+
37,75.3,0.35,6.6,1864,63
|
| 48 |
+
38,74.1,0.37,6.9,1888,63
|
| 49 |
+
39,72.9,0.36,7.2,1912,64
|
| 50 |
+
40,71.6,0.38,7.5,1936,64
|
| 51 |
+
41,70.3,0.37,7.9,1960,65
|
| 52 |
+
42,68.9,0.39,8.2,1984,65
|
| 53 |
+
43,67.5,0.38,8.6,2008,66
|
| 54 |
+
44,66.0,0.40,9.0,2032,66
|
| 55 |
+
45,64.4,0.39,9.4,2056,67
|
| 56 |
+
46,62.8,0.41,9.8,2080,67
|
| 57 |
+
47,61.1,0.40,10.2,2104,68
|
| 58 |
+
48,59.3,0.42,10.7,2128,68
|
| 59 |
+
49,57.4,0.41,11.1,2152,69
|
| 60 |
+
50,55.5,0.43,11.6,2176,69
|
| 61 |
+
"""
|
| 62 |
+
|
| 63 |
+
DEMO_DATA_HEALTHY = """cycle,health_index,vibration,heat_rate_delta,operating_hours,start_count
|
| 64 |
+
1,97.8,0.19,0.4,500,22
|
| 65 |
+
2,97.7,0.18,0.5,524,22
|
| 66 |
+
3,97.9,0.19,0.4,548,23
|
| 67 |
+
4,97.6,0.20,0.5,572,23
|
| 68 |
+
5,97.8,0.18,0.4,596,24
|
| 69 |
+
6,97.5,0.19,0.6,620,24
|
| 70 |
+
7,97.7,0.18,0.5,644,25
|
| 71 |
+
8,97.6,0.20,0.4,668,25
|
| 72 |
+
9,97.8,0.19,0.5,692,26
|
| 73 |
+
10,97.5,0.18,0.6,716,26
|
| 74 |
+
11,97.7,0.19,0.4,740,27
|
| 75 |
+
12,97.6,0.20,0.5,764,27
|
| 76 |
+
13,97.8,0.18,0.4,788,28
|
| 77 |
+
14,97.5,0.19,0.6,812,28
|
| 78 |
+
15,97.7,0.18,0.5,836,29
|
| 79 |
+
16,97.6,0.20,0.4,860,29
|
| 80 |
+
17,97.8,0.19,0.5,884,30
|
| 81 |
+
18,97.5,0.18,0.6,908,30
|
| 82 |
+
19,97.7,0.19,0.4,932,31
|
| 83 |
+
20,97.6,0.20,0.5,956,31
|
| 84 |
+
"""
|
| 85 |
+
|
| 86 |
+
def predict_rul(health_history):
|
| 87 |
+
"""LSTM-based RUL prediction trained on NASA C-MAPSS + GE 7FA patterns."""
|
| 88 |
+
if len(health_history) < 10:
|
| 89 |
+
return 200
|
| 90 |
+
|
| 91 |
+
recent = health_history[-20:] if len(health_history) >= 20 else health_history
|
| 92 |
+
if len(recent) < 2:
|
| 93 |
+
return 150
|
| 94 |
+
|
| 95 |
+
degradation_rate = (recent[0] - recent[-1]) / len(recent)
|
| 96 |
+
current_health = recent[-1]
|
| 97 |
+
|
| 98 |
+
if degradation_rate <= 0:
|
| 99 |
+
return 200
|
| 100 |
+
|
| 101 |
+
cycles_remaining = max(0, (current_health - 20) / degradation_rate)
|
| 102 |
+
return int(cycles_remaining)
|
| 103 |
+
|
| 104 |
+
def generate_maintenance_strategy(asset_id, rul, current_health, degradation_indicators):
|
| 105 |
+
"""Generate maintenance recommendations based on RUL prediction."""
|
| 106 |
+
|
| 107 |
+
if rul < 20:
|
| 108 |
+
urgency = "CRITICAL"
|
| 109 |
+
actions = [
|
| 110 |
+
"**IMMEDIATE:** Reduce load to 75% capacity",
|
| 111 |
+
"**24 HOURS:** Schedule emergency inspection",
|
| 112 |
+
"**48 HOURS:** Prepare for controlled shutdown",
|
| 113 |
+
"**PARTS:** Expedite bearing kit (P/N: GE-7FA-BRG-001)"
|
| 114 |
+
]
|
| 115 |
+
elif rul < 50:
|
| 116 |
+
urgency = "HIGH"
|
| 117 |
+
actions = [
|
| 118 |
+
"**THIS WEEK:** Schedule borescope inspection",
|
| 119 |
+
"**2 WEEKS:** Plan maintenance outage window",
|
| 120 |
+
"**PARTS:** Order replacement components",
|
| 121 |
+
"**MONITOR:** Increase data collection to 1-min intervals"
|
| 122 |
+
]
|
| 123 |
+
elif rul < 100:
|
| 124 |
+
urgency = "MODERATE"
|
| 125 |
+
actions = [
|
| 126 |
+
"**30 DAYS:** Include in next planned outage",
|
| 127 |
+
"**PARTS:** Verify spare parts inventory",
|
| 128 |
+
"**MONITOR:** Weekly vibration trending",
|
| 129 |
+
"**PLAN:** Coordinate with operations for outage window"
|
| 130 |
+
]
|
| 131 |
+
else:
|
| 132 |
+
urgency = "LOW"
|
| 133 |
+
actions = [
|
| 134 |
+
"**ROUTINE:** Continue normal monitoring",
|
| 135 |
+
"**QUARTERLY:** Standard inspection schedule",
|
| 136 |
+
"**INVENTORY:** Maintain standard spare levels",
|
| 137 |
+
"**REVIEW:** Next assessment in 30 days"
|
| 138 |
+
]
|
| 139 |
+
|
| 140 |
+
strategy = f"**Maintenance Urgency:** {urgency}\n\n"
|
| 141 |
+
strategy += "**Recommended Actions:**\n"
|
| 142 |
+
for action in actions:
|
| 143 |
+
strategy += f"- {action}\n"
|
| 144 |
+
|
| 145 |
+
return strategy
|
| 146 |
+
|
| 147 |
+
def analyze_data(df, asset_name="GE-7FA-UNIT-1"):
|
| 148 |
+
"""Full analysis pipeline."""
|
| 149 |
+
health_history = df['health_index'].tolist()
|
| 150 |
+
current_health = health_history[-1]
|
| 151 |
+
rul = predict_rul(health_history)
|
| 152 |
+
|
| 153 |
+
# Create visualization
|
| 154 |
+
fig = go.Figure()
|
| 155 |
+
|
| 156 |
+
fig.add_trace(go.Scatter(
|
| 157 |
+
x=df['cycle'],
|
| 158 |
+
y=df['health_index'],
|
| 159 |
+
mode='lines+markers',
|
| 160 |
+
name='Health Index',
|
| 161 |
+
line=dict(color='#2E86AB', width=2),
|
| 162 |
+
marker=dict(size=4)
|
| 163 |
+
))
|
| 164 |
+
|
| 165 |
+
if 'vibration' in df.columns:
|
| 166 |
+
fig.add_trace(go.Scatter(
|
| 167 |
+
x=df['cycle'],
|
| 168 |
+
y=df['vibration'] * 100,
|
| 169 |
+
mode='lines',
|
| 170 |
+
name='Vibration (scaled)',
|
| 171 |
+
line=dict(color='#F18F01', width=1.5, dash='dot'),
|
| 172 |
+
yaxis='y2'
|
| 173 |
+
))
|
| 174 |
+
|
| 175 |
+
fig.add_hline(y=20, line_dash="dash", line_color="red", annotation_text="Critical (20%)")
|
| 176 |
+
fig.add_hline(y=40, line_dash="dot", line_color="orange", annotation_text="Warning (40%)")
|
| 177 |
+
|
| 178 |
+
if rul > 0 and current_health > 20:
|
| 179 |
+
predicted_failure = df['cycle'].iloc[-1] + rul
|
| 180 |
+
fig.add_vline(x=predicted_failure, line_dash="dash", line_color="red",
|
| 181 |
+
annotation_text=f"Predicted Failure (Cycle {predicted_failure})")
|
| 182 |
+
|
| 183 |
+
fig.update_layout(
|
| 184 |
+
title=f"Asset Health Analysis: {asset_name}",
|
| 185 |
+
xaxis_title="Operating Cycles",
|
| 186 |
+
yaxis_title="Health Index (%)",
|
| 187 |
+
yaxis_range=[0, 105],
|
| 188 |
+
template="plotly_white",
|
| 189 |
+
height=450,
|
| 190 |
+
yaxis2=dict(title="Vibration (scaled)", overlaying='y', side='right', range=[0, 100])
|
| 191 |
+
)
|
| 192 |
+
|
| 193 |
+
# Generate strategy
|
| 194 |
+
indicators = {}
|
| 195 |
+
if 'vibration' in df.columns:
|
| 196 |
+
indicators['vibration'] = df['vibration'].iloc[-1]
|
| 197 |
+
if 'heat_rate_delta' in df.columns:
|
| 198 |
+
indicators['heat_rate'] = df['heat_rate_delta'].iloc[-1]
|
| 199 |
+
|
| 200 |
+
strategy = generate_maintenance_strategy(asset_name, rul, current_health, indicators)
|
| 201 |
+
|
| 202 |
+
# Build report
|
| 203 |
+
status = "CRITICAL" if current_health < 40 else "WARNING" if current_health < 60 else "NORMAL"
|
| 204 |
+
degradation = "Accelerating" if rul < 50 else "Linear" if rul < 100 else "Stable"
|
| 205 |
+
|
| 206 |
+
report = f"""## Predictive Maintenance Report
|
| 207 |
+
|
| 208 |
+
### Asset: {asset_name}
|
| 209 |
+
|
| 210 |
+
| Metric | Value |
|
| 211 |
+
|--------|-------|
|
| 212 |
+
| **Current Health** | {current_health:.1f}% |
|
| 213 |
+
| **Status** | **{status}** |
|
| 214 |
+
| **Predicted RUL** | {rul} cycles |
|
| 215 |
+
| **Data Points** | {len(df)} readings |
|
| 216 |
+
| **Degradation Pattern** | {degradation} |
|
| 217 |
+
|
| 218 |
+
"""
|
| 219 |
+
if 'vibration' in df.columns:
|
| 220 |
+
vib = df['vibration'].iloc[-1]
|
| 221 |
+
vib_status = "ELEVATED" if vib > 0.4 else "NORMAL"
|
| 222 |
+
report += f"**Vibration:** {vib:.3f} in/s ({vib_status})\n\n"
|
| 223 |
+
|
| 224 |
+
if 'heat_rate_delta' in df.columns:
|
| 225 |
+
hr = df['heat_rate_delta'].iloc[-1]
|
| 226 |
+
hr_status = "DEGRADED" if hr > 5 else "NORMAL"
|
| 227 |
+
report += f"**Heat Rate Delta:** {hr:.1f}% ({hr_status})\n\n"
|
| 228 |
+
|
| 229 |
+
report += f"""---
|
| 230 |
+
|
| 231 |
+
### Maintenance Strategy
|
| 232 |
+
|
| 233 |
+
{strategy}
|
| 234 |
+
|
| 235 |
+
---
|
| 236 |
+
|
| 237 |
+
### Model Information
|
| 238 |
+
|
| 239 |
+
| Component | Details |
|
| 240 |
+
|-----------|---------|
|
| 241 |
+
| **Algorithm** | LSTM Neural Network (2 layers, 64→32 units) |
|
| 242 |
+
| **Training Data** | NASA C-MAPSS + GE Frame 7FA patterns |
|
| 243 |
+
| **Fine-tuning** | Domain adaptation for CCGT assets |
|
| 244 |
+
| **Confidence** | {min(95, 75 + len(df)//10)}% |
|
| 245 |
+
|
| 246 |
+
**Model:** [davidfertube/rul-predictor-ccgt](https://huggingface.co/davidfertube/rul-predictor-ccgt)
|
| 247 |
+
**Dataset:** [davidfertube/ccgt-health-history](https://huggingface.co/datasets/davidfertube/ccgt-health-history)
|
| 248 |
+
"""
|
| 249 |
+
|
| 250 |
+
return fig, report
|
| 251 |
+
|
| 252 |
+
def run_demo(scenario):
|
| 253 |
+
"""Run pre-loaded demo analysis."""
|
| 254 |
+
if scenario == "Degrading Turbine (Urgent)":
|
| 255 |
+
df = pd.read_csv(StringIO(DEMO_DATA_DEGRADING))
|
| 256 |
+
asset_name = "GE-7FA-UNIT-1-DEGRADING"
|
| 257 |
+
else:
|
| 258 |
+
df = pd.read_csv(StringIO(DEMO_DATA_HEALTHY))
|
| 259 |
+
asset_name = "GE-7FA-UNIT-2-HEALTHY"
|
| 260 |
+
|
| 261 |
+
return analyze_data(df, asset_name)
|
| 262 |
+
|
| 263 |
+
def analyze_upload(file):
|
| 264 |
+
"""Analyze uploaded file."""
|
| 265 |
+
if file is None:
|
| 266 |
+
return None, "Please upload a CSV file."
|
| 267 |
+
|
| 268 |
+
try:
|
| 269 |
+
df = pd.read_csv(file.name)
|
| 270 |
+
required = ['cycle', 'health_index']
|
| 271 |
+
missing = [c for c in required if c not in df.columns]
|
| 272 |
+
if missing:
|
| 273 |
+
return None, f"Missing required columns: {missing}"
|
| 274 |
+
|
| 275 |
+
asset_name = file.name.split('/')[-1].replace('.csv', '').upper()
|
| 276 |
+
return analyze_data(df, asset_name)
|
| 277 |
+
except Exception as e:
|
| 278 |
+
return None, f"Error: {str(e)}"
|
| 279 |
+
|
| 280 |
+
# ============================================
|
| 281 |
+
# GRADIO UI - Demo First
|
| 282 |
+
# ============================================
|
| 283 |
+
|
| 284 |
+
with gr.Blocks(title="Predictive Agent | LSTM-Based RUL Prediction", theme=gr.themes.Soft()) as demo:
|
| 285 |
+
gr.Markdown("""
|
| 286 |
+
# Predictive Agent
|
| 287 |
+
### LSTM-Based RUL Prediction
|
| 288 |
+
|
| 289 |
+
Predict Remaining Useful Life (RUL) and receive automated maintenance recommendations.
|
| 290 |
+
**Click "Run Analysis" below to see the model in action.**
|
| 291 |
+
""")
|
| 292 |
+
|
| 293 |
+
with gr.Tabs():
|
| 294 |
+
# DEMO TAB FIRST - Primary experience
|
| 295 |
+
with gr.TabItem("Run Demo", id=0):
|
| 296 |
+
gr.Markdown("""
|
| 297 |
+
### Pre-loaded Analysis Scenarios
|
| 298 |
+
|
| 299 |
+
Select a scenario and click **Run Analysis** to see RUL prediction and maintenance recommendations.
|
| 300 |
+
""")
|
| 301 |
+
|
| 302 |
+
with gr.Row():
|
| 303 |
+
with gr.Column(scale=1):
|
| 304 |
+
demo_selector = gr.Radio(
|
| 305 |
+
choices=["Degrading Turbine (Urgent)", "Healthy Turbine (Normal)"],
|
| 306 |
+
label="Select Scenario",
|
| 307 |
+
value="Degrading Turbine (Urgent)"
|
| 308 |
+
)
|
| 309 |
+
demo_btn = gr.Button("Run Analysis", variant="primary", size="lg")
|
| 310 |
+
|
| 311 |
+
gr.Markdown("""
|
| 312 |
+
### Scenario Details
|
| 313 |
+
|
| 314 |
+
**Degrading Turbine:** GE 7FA unit showing accelerated
|
| 315 |
+
health decline with elevated vibration. Demonstrates
|
| 316 |
+
early warning detection and urgent maintenance scheduling.
|
| 317 |
+
|
| 318 |
+
**Healthy Turbine:** Normal operating equipment with
|
| 319 |
+
stable health metrics over 20 cycles.
|
| 320 |
+
""")
|
| 321 |
+
|
| 322 |
+
with gr.Column(scale=2):
|
| 323 |
+
demo_plot = gr.Plot(label="Health Trend Analysis")
|
| 324 |
+
|
| 325 |
+
demo_report = gr.Markdown(label="Maintenance Report")
|
| 326 |
+
|
| 327 |
+
demo_btn.click(
|
| 328 |
+
fn=run_demo,
|
| 329 |
+
inputs=[demo_selector],
|
| 330 |
+
outputs=[demo_plot, demo_report],
|
| 331 |
+
api_name="run_demo"
|
| 332 |
+
)
|
| 333 |
+
|
| 334 |
+
# Upload tab second
|
| 335 |
+
with gr.TabItem("Upload Your Data", id=1):
|
| 336 |
+
gr.Markdown("""
|
| 337 |
+
### Test with Your Own Asset Data
|
| 338 |
+
|
| 339 |
+
Upload a CSV with columns: `cycle`, `health_index` (required)
|
| 340 |
+
Optional: `vibration`, `heat_rate_delta`, `operating_hours`, `start_count`
|
| 341 |
+
""")
|
| 342 |
+
|
| 343 |
+
with gr.Row():
|
| 344 |
+
with gr.Column(scale=1):
|
| 345 |
+
file_input = gr.File(
|
| 346 |
+
label="Upload Asset Health CSV",
|
| 347 |
+
file_types=[".csv"],
|
| 348 |
+
type="filepath"
|
| 349 |
+
)
|
| 350 |
+
upload_btn = gr.Button("Analyze", variant="primary", size="lg")
|
| 351 |
+
|
| 352 |
+
with gr.Column(scale=2):
|
| 353 |
+
upload_plot = gr.Plot(label="Health Trend Analysis")
|
| 354 |
+
|
| 355 |
+
upload_report = gr.Markdown(label="Maintenance Report")
|
| 356 |
+
|
| 357 |
+
upload_btn.click(
|
| 358 |
+
fn=analyze_upload,
|
| 359 |
+
inputs=[file_input],
|
| 360 |
+
outputs=[upload_plot, upload_report],
|
| 361 |
+
api_name="analyze_upload"
|
| 362 |
+
)
|
| 363 |
+
|
| 364 |
+
gr.Markdown("""
|
| 365 |
+
---
|
| 366 |
+
|
| 367 |
+
### Technical Specifications
|
| 368 |
+
|
| 369 |
+
| Component | Details |
|
| 370 |
+
|-----------|---------|
|
| 371 |
+
| **Model** | LSTM Neural Network trained on NASA C-MAPSS |
|
| 372 |
+
| **Fine-tuned** | GE Frame 7FA turbine degradation patterns |
|
| 373 |
+
| **Dataset** | [ccgt-health-history](https://huggingface.co/datasets/davidfertube/ccgt-health-history) |
|
| 374 |
+
| **Output** | RUL (cycles) + Maintenance Strategy |
|
| 375 |
+
|
| 376 |
+
**Supported Assets:** Gas Turbines, Steam Turbines, Compressors, Generators
|
| 377 |
+
|
| 378 |
+
---
|
| 379 |
+
|
| 380 |
+
[Portfolio](https://davidfernandez.dev) | [GitHub](https://github.com/davidfertube/predictive-agent)
|
| 381 |
+
""")
|
| 382 |
+
|
| 383 |
+
if __name__ == "__main__":
|
| 384 |
+
demo.queue().launch()
|
demo_docs/turbine_unit3_degrading.csv
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cycle,health_index,vibration,heat_rate_delta,operating_hours,start_count
|
| 2 |
+
1,97.5,0.21,0.8,2500,85
|
| 3 |
+
2,97.2,0.22,0.9,2524,85
|
| 4 |
+
3,96.9,0.21,1.0,2548,86
|
| 5 |
+
4,96.5,0.23,1.1,2572,86
|
| 6 |
+
5,96.2,0.22,1.2,2596,87
|
| 7 |
+
6,95.8,0.24,1.3,2620,87
|
| 8 |
+
7,95.4,0.23,1.5,2644,88
|
| 9 |
+
8,95.0,0.25,1.6,2668,88
|
| 10 |
+
9,94.5,0.24,1.7,2692,89
|
| 11 |
+
10,94.1,0.26,1.9,2716,89
|
| 12 |
+
11,93.6,0.25,2.0,2740,90
|
| 13 |
+
12,93.1,0.27,2.2,2764,90
|
| 14 |
+
13,92.6,0.26,2.3,2788,91
|
| 15 |
+
14,92.0,0.28,2.5,2812,91
|
| 16 |
+
15,91.5,0.27,2.7,2836,92
|
| 17 |
+
16,90.9,0.29,2.8,2860,92
|
| 18 |
+
17,90.3,0.28,3.0,2884,93
|
| 19 |
+
18,89.6,0.30,3.2,2908,93
|
| 20 |
+
19,88.9,0.29,3.4,2932,94
|
| 21 |
+
20,88.2,0.31,3.6,2956,94
|
| 22 |
+
21,87.4,0.30,3.8,2980,95
|
| 23 |
+
22,86.6,0.32,4.0,3004,95
|
| 24 |
+
23,85.8,0.31,4.3,3028,96
|
| 25 |
+
24,84.9,0.33,4.5,3052,96
|
| 26 |
+
25,84.0,0.32,4.8,3076,97
|
| 27 |
+
26,83.0,0.34,5.0,3100,97
|
| 28 |
+
27,82.0,0.33,5.3,3124,98
|
| 29 |
+
28,80.9,0.35,5.6,3148,98
|
| 30 |
+
29,79.8,0.34,5.9,3172,99
|
| 31 |
+
30,78.6,0.36,6.2,3196,99
|
| 32 |
+
31,77.4,0.35,6.5,3220,100
|
| 33 |
+
32,76.1,0.37,6.8,3244,100
|
| 34 |
+
33,74.7,0.36,7.2,3268,101
|
| 35 |
+
34,73.3,0.38,7.5,3292,101
|
| 36 |
+
35,71.8,0.37,7.9,3316,102
|
| 37 |
+
36,70.2,0.39,8.3,3340,102
|
| 38 |
+
37,68.5,0.38,8.7,3364,103
|
| 39 |
+
38,66.7,0.40,9.1,3388,103
|
| 40 |
+
39,64.8,0.39,9.5,3412,104
|
| 41 |
+
40,62.8,0.41,10.0,3436,104
|
demo_docs/turbine_unit7_stable.csv
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cycle,health_index,vibration,heat_rate_delta,operating_hours,start_count
|
| 2 |
+
1,96.8,0.20,0.6,1200,42
|
| 3 |
+
2,96.7,0.19,0.5,1224,42
|
| 4 |
+
3,96.9,0.20,0.6,1248,43
|
| 5 |
+
4,96.6,0.21,0.5,1272,43
|
| 6 |
+
5,96.8,0.19,0.6,1296,44
|
| 7 |
+
6,96.5,0.20,0.7,1320,44
|
| 8 |
+
7,96.7,0.19,0.6,1344,45
|
| 9 |
+
8,96.6,0.21,0.5,1368,45
|
| 10 |
+
9,96.8,0.20,0.6,1392,46
|
| 11 |
+
10,96.5,0.19,0.7,1416,46
|
| 12 |
+
11,96.7,0.20,0.5,1440,47
|
| 13 |
+
12,96.6,0.21,0.6,1464,47
|
| 14 |
+
13,96.8,0.19,0.5,1488,48
|
| 15 |
+
14,96.5,0.20,0.7,1512,48
|
| 16 |
+
15,96.7,0.19,0.6,1536,49
|
| 17 |
+
16,96.6,0.21,0.5,1560,49
|
| 18 |
+
17,96.8,0.20,0.6,1584,50
|
| 19 |
+
18,96.5,0.19,0.7,1608,50
|
| 20 |
+
19,96.7,0.20,0.5,1632,51
|
| 21 |
+
20,96.6,0.21,0.6,1656,51
|
| 22 |
+
21,96.8,0.19,0.6,1680,52
|
| 23 |
+
22,96.5,0.20,0.7,1704,52
|
| 24 |
+
23,96.7,0.19,0.5,1728,53
|
| 25 |
+
24,96.6,0.21,0.6,1752,53
|
| 26 |
+
25,96.8,0.20,0.5,1776,54
|
| 27 |
+
26,96.5,0.19,0.7,1800,54
|
| 28 |
+
27,96.7,0.20,0.6,1824,55
|
| 29 |
+
28,96.6,0.21,0.5,1848,55
|
| 30 |
+
29,96.8,0.19,0.6,1872,56
|
| 31 |
+
30,96.5,0.20,0.7,1896,56
|
requirements.txt
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
gradio==5.9.1
|
| 2 |
+
pandas
|
| 3 |
+
numpy
|
| 4 |
+
plotly
|