You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit b0f1fb8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(load-ml): stop a training run that crosses midnight inflating the forecast (#4537)
The load baseline (load_minutes_now, cumulative load since local midnight) is
captured during the data fetch, while minutes_now is read live from the base at
publish time. Training runs for many minutes, so when a fine-tune starts before
midnight and finishes after it the two disagree: minutes_now has reset to the new
day but the baseline still holds yesterday's full daily total, which then gets
added on top of every published forecast point.
Seen in the wild as a single-sample spike in the ML load chart - a fetch at 23:50
followed by training that completed at 00:15 published load_today_h1 of ~25 kWh
and load_today_h8 of ~30 kWh against an actual daily total of 25 kWh. The next
cycle re-fetched and the values returned to normal.
Re-fetch after training whenever the data has gone stale, which re-anchors both
the baseline and the lookback window feeding the prediction to the current time.
As a second line of defence, detect a baseline snapshot belonging to a previous
day at publish time and re-derive it from the per-step load history instead.
Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
self.log("Warn: ML Component: Failed to fetch load data, no data was returned.")
615
+
self.log("ML Component: Data fetch completed, load data age {:.1f} days, {} data points".format(self.load_data_age_days, len(self.load_data) ifself.load_dataelse0))
# Shift existing data to keep it anchored to 'minutes ago from now' before fetching new data, so that we can merge them and preserve historical depth even if the fetch returns limited history
self.log("Warn: ML Component: Failed to fetch load data, no data was returned.")
712
-
self.log("ML Component: Data fetch completed, load data age {:.1f} days, {} data points".format(self.load_data_age_days, len(self.load_data) ifself.load_dataelse0))
"Warn: ML Component: Load baseline of {} kWh was captured on {} which is a previous day, re-derived load so far today as {} kWh".format(dp2(self.load_minutes_now), self.load_minutes_now_time.strftime("%Y-%m-%d %H:%M"), dp2(derived_baseline))
1058
+
)
1059
+
returnderived_baseline
1060
+
1010
1061
def_publish_entity(self):
1011
1062
"""Publish the load_forecast_ml entity with current predictions."""
1012
1063
# Convert predictions to timestamp format for entity
0 commit comments