Skip to content

physXAI 1.0.0 – Phase 1: leakage free data pipeline - #71

Merged
PatrickHenkel1 merged 5 commits into
refactoring_v1.0.0from
v1/phase-1-data
Nov 6, 2026
Merged

PatrickHenkel1 merged 5 commits into
refactoring_v1.0.0from
v1/phase-1-data

Conversation

@PatrickHenkel1

Copy link
Copy Markdown
Collaborator

Phase 1 of the physXAI 1.0.0 refactoring: leakage free data pipeline. Follows #70.

Summary

  • BlockSplit (physXAI/preprocessing/splitting.py):
    • contiguous blocks are assigned to train/val/test, drawn stratified over the time axis so every split covers all seasons;
    • embargo gap_steps between splits (default: max lag + shift);
    • strategies blocks (default), holdout_end, random_rows (legacy).
  • Windows are only cut out of one split (windows.py), so multi step training and test windows never overlap (fixes the leakage of timeseries_dataset_from_array + take/skip). Training windows are reshuffled every epoch.
  • Regular time grid: missing time stamps become invalid rows. Targets are never paired across gaps; this fixes the ignore_nan=True bug, which is active in typical runs.
  • Native X_lagN / Change(X) columns, plus lags={'X': n}, a transform(df) hook, datetime indices and eval_horizon / eval_stride (used by the recursive evaluation in phase 3). Constructed features still work during the transition.
  • TrainingData holds the whole series as NumPy with split labels and a validity mask, and is saved/loaded without pickle. TrainingDataMultiStep is built from NumPy windows; tf.data is created on demand.
  • physXAI.set_seed(seed): one global seed (Python, NumPy, Keras) and the default random_state. The used seed is always stored in the config.
  • Configs: get_config / from_config are complete (csv options, split, ignore_nan …) and dispatch on __class_name__. The AgentLib-MPC keys are unchanged.
  • .gitattributes normalizes line endings (Windows / Linux).

Behaviour changes

  • Single step data is split in blocks by default. Test metrics get more realistic: autocorrelated random rows overestimated them. split='random_rows' restores the old behaviour.

Test plan

  • pytest: 65 passed, including 22 new tests for splitting, windows, preprocessing, the gap regression and leakage.
  • AgentLib-MPC contract tests pass.
  • verify_installation.py and TAir_evaluateMultiStep.py run.
  • CI on Linux and Windows.

🤖 Generated with Claude Code

PatrickHenkel1 and others added 2 commits November 6, 2026 01:16
- BlockSplit: stratified blocks with embargo (default), holdout_end and
  random_rows; windows are only cut out of one split, so training and
  test windows never overlap (fixes data leakage of multi step data)
- Regular time grid when loading: missing time stamps become invalid rows,
  targets are never paired across gaps (fixes ignore_nan bug)
- Native X_lagN and Change(X) columns, lags dict, transform hook, datetime
  index, eval_horizon / eval_stride for single step models
- TrainingData holds the whole series as numpy with split labels and
  validity mask, save / load without pickle; TrainingDataMultiStep is built
  from numpy windows and creates tf.data pipelines on demand
- physXAI.set_seed: global seed, used as default random_state
- Complete get_config / from_config with class dispatch
- Tests for splitting, windows, preprocessing and regressions

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 6, 2026 00:17

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.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

PatrickHenkel1 and others added 3 commits November 6, 2026 01:17
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PatrickHenkel1
PatrickHenkel1 merged commit 2ca9353 into refactoring_v1.0.0 Nov 6, 2026
@PatrickHenkel1
PatrickHenkel1 deleted the v1/phase-1-data branch November 6, 2026 06:18
@PatrickHenkel1 PatrickHenkel1 mentioned this pull request Nov 8, 2026
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.

3 participants