Garg06 commited on
Commit
759a2cd
Β·
verified Β·
1 Parent(s): 1fbe497

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +24 -1
app.py CHANGED
@@ -63,7 +63,7 @@ coolant_temp = st.number_input(
63
  help='Engine coolant temperature in Β°C. Normal range: 74–83 Β°C.'
64
  )
65
 
66
- # ── Assemble input dataframe ──────────────────────────────────────────────
67
  # Column names must exactly match those used during model training.
68
  input_data = pd.DataFrame([{
69
  'Engine rpm': engine_rpm,
@@ -74,6 +74,29 @@ input_data = pd.DataFrame([{
74
  'Coolant temp': coolant_temp,
75
  }])
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # ── Prediction ────────────────────────────────────────────────────────────
78
  if st.button('Predict Engine Condition'):
79
  prediction = model.predict(input_data)[0]
 
63
  help='Engine coolant temperature in Β°C. Normal range: 74–83 Β°C.'
64
  )
65
 
66
+ # ── Assemble raw sensor input ─────────────────────────────────────────────
67
  # Column names must exactly match those used during model training.
68
  input_data = pd.DataFrame([{
69
  'Engine rpm': engine_rpm,
 
74
  'Coolant temp': coolant_temp,
75
  }])
76
 
77
+ # ── Feature engineering β€” must match prep.py exactly ─────────────────────
78
+ # The model was trained on 12 features (6 raw + 6 engineered).
79
+ # The saved Pipeline handles StandardScaling internally.
80
+ eps = 1e-6
81
+ input_data['pressure_ratio_fuel_coolant'] = (
82
+ input_data['Fuel pressure'] / (input_data['Coolant pressure'] + eps)
83
+ )
84
+ input_data['temp_delta_oil_coolant'] = (
85
+ input_data['lub oil temp'] - input_data['Coolant temp']
86
+ )
87
+ input_data['lub_pressure_per_rpm'] = (
88
+ (input_data['Lub oil pressure'] / (input_data['Engine rpm'] + eps)) * 1000
89
+ )
90
+ input_data['coolant_pressure_per_rpm'] = (
91
+ (input_data['Coolant pressure'] / (input_data['Engine rpm'] + eps)) * 1000
92
+ )
93
+ input_data['thermal_stress_index'] = (
94
+ (input_data['lub oil temp'] + input_data['Coolant temp']) / 2
95
+ )
96
+ input_data['pressure_diff_fuel_lub'] = (
97
+ input_data['Fuel pressure'] - input_data['Lub oil pressure']
98
+ )
99
+
100
  # ── Prediction ────────────────────────────────────────────────────────────
101
  if st.button('Predict Engine Condition'):
102
  prediction = model.predict(input_data)[0]