Apply changes from PR #391 by @MarcoGorworworelli:
- Fix train_gen() to iterate in proper batch_size chunks instead of
yielding all time series at once when permute=False
- Add test_data_loader.py to verify batch boundaries
Apply changes from PR #393 by @MarcoGorworworelli:
- Normalize covariates per-input instead of batch-wide to prevent
each input's result from depending on batch composition
- Fit separate ridge regressions per time series instead of a single
batched regression, preventing cross-series data leakage
- Applied to both src/timesfm/utils/xreg_lib.py and v1/src/timesfm/xreg_lib.py
1. Masked variance calculation (lines 95-107): Changed from the numerically unstable E[X²] - E[X]² formula to the stable centered formula E[(X-μ)²]
2. Sigma clamping (line 609): Changed from torch.where(sigma < tolerance, 1.0, sigma) to torch.clamp(sigma, min=tolerance)