Skip to content

Fix ML load inflation: skip clean_incrementing_reverse for power sensors - #3784

Merged
springfall2008 merged 1 commit into
springfall2008:mainfrom
amasolov:fix/ml-load-power-clean-increment
Apr 14, 2026
Merged

springfall2008 merged 1 commit into
springfall2008:mainfrom
amasolov:fix/ml-load-power-clean-increment

Conversation

@amasolov

Copy link
Copy Markdown
Contributor

Summary

minute_data_load unconditionally applied clean_incrementing_reverse to 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_power sensors that report instantaneous watts (fluctuating values like 300 W → 900 W → 400 W), clean_incrementing_reverse misinterprets 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_power then 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: Add clean_increment parameter to minute_data_load (default True for backward compatibility). Pass clean_increment=False when fetching load_power data in both the standard and GE Cloud paths.
  • load_ml_component.py: Same fix for the load_power fetch 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 to fill_load_from_power.

Root cause

load_power sensor (instantaneous W):   600, 900, 400, 800, 300, 700, ...
                                           ↓
         clean_incrementing_reverse (bug: treats drops as resets)
                                           ↓
distorted "power" data:                600, 1500, 1500, 2300, 2300, 3000, ...
                                           ↓
         fill_load_from_power (integrates inflated values)
                                           ↓
cumulative load inflated by ~2x

Test plan

  • New regression test test_fill_load_from_power_distorted_power_inflation passes — demonstrates 2.39x inflation with distorted data
  • All existing test_fill_load_from_power tests pass (no regressions)
  • All test_load_ml tests pass (27/27)
  • unit_test.py --quick passes (pre-existing history_attribute Test 11 failure unrelated)
  • Pre-commit checks pass (ruff, black, cspell, trailing whitespace)

Fixes #3692

Made with Cursor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_increment parameter to Fetch.minute_data_load (defaulting to True) and threaded it into the underlying minute_data(...) call.
  • Updated both core fetch flow and the LoadML component to fetch load_power with clean_increment=False.
  • Added a regression test demonstrating the distortion/inflation mechanism when clean_incrementing_reverse is 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.

@springfall2008
springfall2008 merged commit ea306d3 into springfall2008:main Apr 14, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The values used for the LoadML Actual Load data is much higher than my actual load use.

3 participants