Repository navigation
Fix ML load inflation: skip clean_incrementing_reverse for power sensors - #3784
Merged
springfall2008 merged 1 commit intoApr 14, 2026
Merged
springfall2008 merged 1 commit into
springfall2008 merged 1 commit into
Conversation
minute_data_load applied clean_incrementing_reverse (designed for cumulative kWh counters) to load_power sensors that report instantaneous watts. This converted fluctuating power readings into an ever-growing cumulative series, causing fill_load_from_power gap-fills to inject vastly inflated energy — resulting in ML actual load showing ~2x real consumption. Add a clean_increment parameter to minute_data_load (default True for backward compatibility) and set it to False for all load_power fetches in fetch.py and load_ml_component.py. Add regression test demonstrating the inflation mechanism. Fixes springfall2008#3692 Made-with: Cursor
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes LoadML “actual load” inflation by preventing cumulative-counter cleanup logic from being applied to instantaneous load_power sensors, avoiding distorted power series that over-inflate fill_load_from_power gap fills and ML training data.
Changes:
- Added a
clean_incrementparameter toFetch.minute_data_load(defaulting toTrue) and threaded it into the underlyingminute_data(...)call. - Updated both core fetch flow and the LoadML component to fetch
load_powerwithclean_increment=False. - Added a regression test demonstrating the distortion/inflation mechanism when
clean_incrementing_reverseis incorrectly applied to fluctuating power readings.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/predbat/fetch.py | Adds clean_increment flag to minute_data_load and disables increment-cleaning when loading load_power for gap filling. |
| apps/predbat/load_ml_component.py | Fetches load_power history with clean_increment=False before calling fill_load_from_power. |
| apps/predbat/tests/test_fill_load_from_power.py | Adds regression coverage proving distorted “power” can inflate cumulative load totals and ensures correct behavior with undistorted power. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
minute_data_loadunconditionally appliedclean_incrementing_reverseto every sensor it loaded. This function is designed for cumulative kWh counters — it detects "resets" (where the counter drops back to 0) and stitches them into a monotonically increasing series.When applied to
load_powersensors that report instantaneous watts (fluctuating values like 300 W → 900 W → 400 W),clean_incrementing_reversemisinterprets every natural drop as a "reset" and accumulates all positive increments into an ever-growing cumulative series. A realistic ~600 W signal becomes a series peaking at ~20,000+ W.fill_load_from_powerthen integrates this vastly inflated "power" data to fill zero-load periods, injecting far too much energy and shifting the entire cumulative load curve upwards. The result: ML actual load showing ~2x real consumption, causing the ML model to train on inflated data and over-predict future load.Changes
fetch.py: Addclean_incrementparameter tominute_data_load(defaultTruefor backward compatibility). Passclean_increment=Falsewhen fetchingload_powerdata in both the standard and GE Cloud paths.load_ml_component.py: Same fix for theload_powerfetch in_fetch_load_data.tests/test_fill_load_from_power.py: Add regression test that demonstrates the inflation mechanism — shows ~2.4x total energy inflation when distorted power data is fed tofill_load_from_power.Root cause
Test plan
test_fill_load_from_power_distorted_power_inflationpasses — demonstrates 2.39x inflation with distorted datatest_fill_load_from_powertests pass (no regressions)test_load_mltests pass (27/27)unit_test.py --quickpasses (pre-existinghistory_attributeTest 11 failure unrelated)Fixes #3692
Made with Cursor