Jompatron commited on
Commit
b241f9d
·
1 Parent(s): 88dedfd
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -326,14 +326,14 @@ def generate_hindcast(sensor_internal: str, days: int) -> str | None:
326
  df["sensor_whitehall_street"] = sensor_flags["sensor_whitehall_street"]
327
 
328
  # Convert date to ordinal (model expects numeric date)
329
- df["date"] = df["date"].apply(lambda d: d.toordinal())
330
 
331
- # Build X with exact required order
332
- X_df = df[feature_order]
333
 
334
  # Predict hindcast
335
  df["predicted_pm25"] = model.predict(X_df)
336
- df_hind = df
337
 
338
  tmp_path = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
339
  sensor_label = SENSOR_LABELS[sensor_internal]
 
326
  df["sensor_whitehall_street"] = sensor_flags["sensor_whitehall_street"]
327
 
328
  # Convert date to ordinal (model expects numeric date)
329
+ df["date_ordinal"] = df["date"].apply(lambda d: d.toordinal())
330
 
331
+ # Build X with correct order using the ordinal date
332
+ X_df = df.assign(date=df["date_ordinal"])[feature_order]
333
 
334
  # Predict hindcast
335
  df["predicted_pm25"] = model.predict(X_df)
336
+ df_hind = df # df still has real dates!
337
 
338
  tmp_path = tempfile.NamedTemporaryFile(suffix=".png", delete=False).name
339
  sensor_label = SENSOR_LABELS[sensor_internal]