Spaces:
Sleeping
Sleeping
Update Streamlit app
Browse files
app.py
CHANGED
|
@@ -40,40 +40,36 @@ def engineer_features(df):
|
|
| 40 |
"""Apply feature engineering to match training pipeline exactly"""
|
| 41 |
df_enhanced = df.copy()
|
| 42 |
|
| 43 |
-
#
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
"Engine rpm": "Engine RPM",
|
| 49 |
-
"Fuel pressure": "Fuel Pressure",
|
| 50 |
-
"Coolant pressure": "Coolant Pressure"
|
| 51 |
-
}
|
| 52 |
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
| 56 |
|
| 57 |
-
#
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
|
| 60 |
-
#
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
for col in sensor_columns:
|
| 73 |
-
if col in df_enhanced.columns:
|
| 74 |
-
df_enhanced[f'{col}_Squared'] = df_enhanced[col] ** 2
|
| 75 |
|
| 76 |
-
return df_enhanced
|
| 77 |
|
| 78 |
# ============================================
|
| 79 |
# MAIN APP
|
|
|
|
| 40 |
"""Apply feature engineering to match training pipeline exactly"""
|
| 41 |
df_enhanced = df.copy()
|
| 42 |
|
| 43 |
+
# Create the three derived features that the model was trained with
|
| 44 |
+
# Lub_Stress_Index = Lub oil pressure * lub oil temp
|
| 45 |
+
df_enhanced['Lub_Stress_Index'] = (
|
| 46 |
+
df_enhanced['Lub oil pressure'] * df_enhanced['lub oil temp']
|
| 47 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
# Thermal_Efficiency = Coolant pressure / (Coolant temp + 1e-5)
|
| 50 |
+
df_enhanced['Thermal_Efficiency'] = (
|
| 51 |
+
df_enhanced['Coolant pressure'] / (df_enhanced['Coolant temp'] + 1e-5)
|
| 52 |
+
)
|
| 53 |
|
| 54 |
+
# Power_Load_Index = Engine rpm * Fuel pressure
|
| 55 |
+
df_enhanced['Power_Load_Index'] = (
|
| 56 |
+
df_enhanced['Engine rpm'] * df_enhanced['Fuel pressure']
|
| 57 |
+
)
|
| 58 |
|
| 59 |
+
# Return features in EXACT order the model was trained with
|
| 60 |
+
feature_order = [
|
| 61 |
+
'Engine rpm',
|
| 62 |
+
'Lub oil pressure',
|
| 63 |
+
'Fuel pressure',
|
| 64 |
+
'Coolant pressure',
|
| 65 |
+
'lub oil temp',
|
| 66 |
+
'Coolant temp',
|
| 67 |
+
'Lub_Stress_Index',
|
| 68 |
+
'Thermal_Efficiency',
|
| 69 |
+
'Power_Load_Index'
|
| 70 |
+
]
|
|
|
|
|
|
|
|
|
|
| 71 |
|
| 72 |
+
return df_enhanced[feature_order]
|
| 73 |
|
| 74 |
# ============================================
|
| 75 |
# MAIN APP
|