Skip to content

Speed up seasonal error calculation#85

Merged
shchur merged 2 commits intomainfrom
faster-metrics
Jan 13, 2026
Merged

Speed up seasonal error calculation#85
shchur merged 2 commits intomainfrom
faster-metrics

Conversation

@shchur
Copy link
Contributor

@shchur shchur commented Jan 13, 2026

Issue #, if available:

Description of changes:

  • Speed up the calculation of seasonal error by using an efficient implementation based on np.bincount instead of Dataset.map
● Here are the benchmark results on the M5 dataset (30,490 time series):
  ┌──────────────────────────────────┬───────────┬────────────────┬─────────┐
  │             Function             │ OLD (map) │ NEW (bincount) │ Speedup │
  ├──────────────────────────────────┼───────────┼────────────────┼─────────┤
  │ _abs_seasonal_error_per_item     │ 20.039s   │ 2.527s         │ 7.9x    │
  ├──────────────────────────────────┼───────────┼────────────────┼─────────┤
  │ _squared_seasonal_error_per_item │ 20.101s   │ 2.486s         │ 8.1x    │
  └──────────────────────────────────┴───────────┴────────────────┴─────────┘
  Both implementations produce identical results (verified with np.allclose).

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@shchur shchur requested a review from abdulfatir January 13, 2026 14:12
@shchur shchur merged commit 80b3a05 into main Jan 13, 2026
5 checks passed
@shchur shchur deleted the faster-metrics branch January 13, 2026 15:28
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.

2 participants