forecastforge 0.4.0__tar.gz → 0.5.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (157) hide show
  1. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/workflows/pypi.yml +27 -6
  2. {forecastforge-0.4.0 → forecastforge-0.5.0}/CHANGELOG.md +29 -1
  3. {forecastforge-0.4.0 → forecastforge-0.5.0}/CITATION.cff +1 -1
  4. {forecastforge-0.4.0 → forecastforge-0.5.0}/CONTRIBUTING.md +8 -0
  5. {forecastforge-0.4.0 → forecastforge-0.5.0}/PKG-INFO +34 -5
  6. {forecastforge-0.4.0 → forecastforge-0.5.0}/README.md +33 -4
  7. forecastforge-0.5.0/VERSION +1 -0
  8. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/evaluation.md +4 -0
  9. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/overview.md +8 -4
  10. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/cli.md +38 -0
  11. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/index.md +8 -0
  12. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/publishing.md +15 -5
  13. {forecastforge-0.4.0 → forecastforge-0.5.0}/pyproject.toml +1 -1
  14. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/__init__.py +1 -1
  15. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/cli/main.py +90 -21
  16. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/evaluation/__init__.py +6 -0
  17. forecastforge-0.5.0/src/forecastforge/evaluation/compare.py +102 -0
  18. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/cli/test_main.py +90 -0
  19. forecastforge-0.5.0/tests/evaluation/test_compare.py +105 -0
  20. forecastforge-0.4.0/VERSION +0 -1
  21. {forecastforge-0.4.0 → forecastforge-0.5.0}/.dockerignore +0 -0
  22. {forecastforge-0.4.0 → forecastforge-0.5.0}/.editorconfig +0 -0
  23. {forecastforge-0.4.0 → forecastforge-0.5.0}/.env.example +0 -0
  24. {forecastforge-0.4.0 → forecastforge-0.5.0}/.gitattributes +0 -0
  25. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  26. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  27. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  28. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/dependabot.yml +0 -0
  29. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/pull_request_template.md +0 -0
  30. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/workflows/ci.yml +0 -0
  31. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/workflows/docs.yml +0 -0
  32. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/workflows/release.yml +0 -0
  33. {forecastforge-0.4.0 → forecastforge-0.5.0}/.github/workflows/security.yml +0 -0
  34. {forecastforge-0.4.0 → forecastforge-0.5.0}/.gitignore +0 -0
  35. {forecastforge-0.4.0 → forecastforge-0.5.0}/.pre-commit-config.yaml +0 -0
  36. {forecastforge-0.4.0 → forecastforge-0.5.0}/CODE_OF_CONDUCT.md +0 -0
  37. {forecastforge-0.4.0 → forecastforge-0.5.0}/LICENSE +0 -0
  38. {forecastforge-0.4.0 → forecastforge-0.5.0}/Makefile +0 -0
  39. {forecastforge-0.4.0 → forecastforge-0.5.0}/SECURITY.md +0 -0
  40. {forecastforge-0.4.0 → forecastforge-0.5.0}/configs/development.toml +0 -0
  41. {forecastforge-0.4.0 → forecastforge-0.5.0}/configs/logging.yaml +0 -0
  42. {forecastforge-0.4.0 → forecastforge-0.5.0}/configs/production.toml +0 -0
  43. {forecastforge-0.4.0 → forecastforge-0.5.0}/configs/settings.toml +0 -0
  44. {forecastforge-0.4.0 → forecastforge-0.5.0}/configs/testing.toml +0 -0
  45. {forecastforge-0.4.0 → forecastforge-0.5.0}/docker/Dockerfile +0 -0
  46. {forecastforge-0.4.0 → forecastforge-0.5.0}/docker-compose.yml +0 -0
  47. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/README.md +0 -0
  48. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/adr/0001-use-src-layout.md +0 -0
  49. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/cli.md +0 -0
  50. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/config.md +0 -0
  51. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/core.md +0 -0
  52. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/data.md +0 -0
  53. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/features.md +0 -0
  54. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/models.md +0 -0
  55. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/pipelines.md +0 -0
  56. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/api/schemas.md +0 -0
  57. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/architecture.md +0 -0
  58. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/assets/backtest_overview.png +0 -0
  59. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/assets/benchmark_mase.png +0 -0
  60. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/assets/benchmark_results.md +0 -0
  61. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/assets/feature_overview.png +0 -0
  62. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/assets/synthetic_spy_demo.png +0 -0
  63. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/data-pipeline.md +0 -0
  64. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/development.md +0 -0
  65. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/feature-engineering.md +0 -0
  66. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/model-comparison.md +0 -0
  67. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/monitoring.md +0 -0
  68. {forecastforge-0.4.0 → forecastforge-0.5.0}/docs/serving.md +0 -0
  69. {forecastforge-0.4.0 → forecastforge-0.5.0}/examples/01_synthetic_data.py +0 -0
  70. {forecastforge-0.4.0 → forecastforge-0.5.0}/examples/02_features.py +0 -0
  71. {forecastforge-0.4.0 → forecastforge-0.5.0}/examples/03_backtesting.py +0 -0
  72. {forecastforge-0.4.0 → forecastforge-0.5.0}/mkdocs.yml +0 -0
  73. {forecastforge-0.4.0 → forecastforge-0.5.0}/notebooks/.gitkeep +0 -0
  74. {forecastforge-0.4.0 → forecastforge-0.5.0}/pipelines/.gitkeep +0 -0
  75. {forecastforge-0.4.0 → forecastforge-0.5.0}/scripts/bootstrap.ps1 +0 -0
  76. {forecastforge-0.4.0 → forecastforge-0.5.0}/scripts/bootstrap.sh +0 -0
  77. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/cli/__init__.py +0 -0
  78. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/cli/__main__.py +0 -0
  79. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/common/__init__.py +0 -0
  80. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/__init__.py +0 -0
  81. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/_optional.py +0 -0
  82. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/device.py +0 -0
  83. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/environment.py +0 -0
  84. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/paths.py +0 -0
  85. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/runtime.py +0 -0
  86. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/seed.py +0 -0
  87. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/config/settings.py +0 -0
  88. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/core/__init__.py +0 -0
  89. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/core/errors.py +0 -0
  90. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/data/__init__.py +0 -0
  91. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/data/loaders.py +0 -0
  92. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/data/source.py +0 -0
  93. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/data/synthetic.py +0 -0
  94. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/data/yfinance_source.py +0 -0
  95. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/evaluation/backtest.py +0 -0
  96. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/evaluation/benchmark.py +0 -0
  97. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/evaluation/metrics.py +0 -0
  98. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/features/__init__.py +0 -0
  99. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/features/builtins.py +0 -0
  100. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/features/frame.py +0 -0
  101. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/features/pipeline.py +0 -0
  102. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/features/transform.py +0 -0
  103. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/models/__init__.py +0 -0
  104. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/models/base.py +0 -0
  105. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/models/baselines.py +0 -0
  106. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/models/gbm.py +0 -0
  107. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/models/statistical.py +0 -0
  108. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/monitoring/__init__.py +0 -0
  109. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/pipelines/__init__.py +0 -0
  110. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/pipelines/synthetic_backtest.py +0 -0
  111. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/py.typed +0 -0
  112. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/schemas/__init__.py +0 -0
  113. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/schemas/time_series.py +0 -0
  114. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/schemas/validation.py +0 -0
  115. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/serving/__init__.py +0 -0
  116. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/tracking/__init__.py +0 -0
  117. {forecastforge-0.4.0 → forecastforge-0.5.0}/src/forecastforge/utils/__init__.py +0 -0
  118. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/__init__.py +0 -0
  119. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/cli/__init__.py +0 -0
  120. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/__init__.py +0 -0
  121. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_device.py +0 -0
  122. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_environment.py +0 -0
  123. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_optional.py +0 -0
  124. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_paths.py +0 -0
  125. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_runtime.py +0 -0
  126. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_seed.py +0 -0
  127. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/config/test_settings.py +0 -0
  128. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/conftest.py +0 -0
  129. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/core/__init__.py +0 -0
  130. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/core/test_errors.py +0 -0
  131. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/data/__init__.py +0 -0
  132. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/data/test_loaders.py +0 -0
  133. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/data/test_synthetic.py +0 -0
  134. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/data/test_yfinance_source.py +0 -0
  135. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/evaluation/__init__.py +0 -0
  136. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/evaluation/test_backtest.py +0 -0
  137. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/evaluation/test_benchmark.py +0 -0
  138. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/evaluation/test_metrics.py +0 -0
  139. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/__init__.py +0 -0
  140. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/conftest.py +0 -0
  141. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/helpers.py +0 -0
  142. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/test_builtins.py +0 -0
  143. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/test_frame.py +0 -0
  144. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/test_leakage.py +0 -0
  145. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/test_pipeline.py +0 -0
  146. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/features/test_transform.py +0 -0
  147. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/models/__init__.py +0 -0
  148. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/models/test_base.py +0 -0
  149. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/models/test_baselines.py +0 -0
  150. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/models/test_gbm.py +0 -0
  151. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/models/test_statistical.py +0 -0
  152. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/pipelines/__init__.py +0 -0
  153. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/pipelines/test_synthetic_backtest.py +0 -0
  154. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/schemas/__init__.py +0 -0
  155. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/schemas/test_time_series.py +0 -0
  156. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/schemas/test_validation.py +0 -0
  157. {forecastforge-0.4.0 → forecastforge-0.5.0}/tests/test_package_metadata.py +0 -0
@@ -1,6 +1,6 @@
1
1
  name: PyPI
2
2
 
3
- # Publish the distribution to PyPI when a GitHub release is published.
3
+ # Publish the distribution to PyPI after a successful release run.
4
4
  #
5
5
  # Authentication uses OpenID Connect through PyPI's Trusted Publisher
6
6
  # mechanism: the workflow mints a short-lived token, and PyPI validates it
@@ -9,13 +9,24 @@ name: PyPI
9
9
  # docs/publishing.md and must be completed before the first release reaches
10
10
  # this workflow, otherwise the publish job fails at the OIDC step.
11
11
  #
12
- # The trigger is the release event rather than the tag push, so the
13
- # artifacts that reach PyPI are built from exactly the commit a maintainer
14
- # reviewed when publishing the GitHub release.
12
+ # The trigger is the completion of the Release workflow rather than the
13
+ # release event. The release workflow creates the release with the default
14
+ # GITHUB_TOKEN, and GitHub does not emit workflow events for actions taken
15
+ # by GITHUB_TOKEN, so a release trigger would never fire. Handing off on
16
+ # the Release run preserves the original ordering — PyPI is built only
17
+ # after the release exists — and checks out the same tag the maintainer
18
+ # pushed, because a tag-triggered Release run reports the tag as its
19
+ # head_branch.
20
+ #
21
+ # workflow_dispatch is the escape hatch: a maintainer can publish (or
22
+ # re-publish) an existing tag, for example after fixing a Trusted
23
+ # Publisher record, by dispatching this workflow with the tag as the ref.
15
24
 
16
25
  on:
17
- release:
18
- types: [published]
26
+ workflow_run:
27
+ workflows: ["Release"]
28
+ types: [completed]
29
+ workflow_dispatch:
19
30
 
20
31
  permissions: {}
21
32
 
@@ -25,6 +36,11 @@ env:
25
36
  jobs:
26
37
  build:
27
38
  name: Build the distribution
39
+ # workflow_run fires for every Release completion; build only when the
40
+ # release chain actually succeeded, or when dispatched by hand.
41
+ if: >-
42
+ github.event_name == 'workflow_dispatch' ||
43
+ github.event.workflow_run.conclusion == 'success'
28
44
  runs-on: ubuntu-latest
29
45
  timeout-minutes: 15
30
46
  permissions:
@@ -32,6 +48,11 @@ jobs:
32
48
  steps:
33
49
  - name: Checkout repository
34
50
  uses: actions/checkout@v7
51
+ with:
52
+ # A workflow_run event fires with the default branch checked out;
53
+ # build the tag the Release run verified instead. A dispatched run
54
+ # resolves to the ref it was dispatched with.
55
+ ref: ${{ github.event.workflow_run.head_branch || github.ref }}
35
56
 
36
57
  - name: Set up Python 3.12
37
58
  uses: actions/setup-python@v7
@@ -5,7 +5,35 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
- ## [Unreleased]
8
+ ## [0.5.0] - 2026-12-02
9
+
10
+ Model selection: the baselines can now be ranked against each other by any
11
+ report metric, and each model's error decay over the horizon is one command
12
+ away.
13
+
14
+ ### Added
15
+
16
+ - A `compare` subcommand for the console script: backtest the chosen
17
+ baselines against the same walk-forward folds, print the metrics table
18
+ sorted best-first by `--metric` (one of `mae`, `rmse`, `smape`, `mase`,
19
+ and `directional_accuracy`, default `mase`), then the MAE of each model
20
+ at every horizon step pooled across folds. `--output` writes the sorted
21
+ ranking table in the usual CSV/Parquet convention.
22
+ - `rank_models` and `mae_by_step` in the new
23
+ `forecastforge.evaluation.compare` module — the pure functions behind the
24
+ report — exported from `forecastforge.evaluation`.
25
+ - Documentation: PyPI badges (package version, supported Python versions,
26
+ latest release) and the CodeQL badge on the README with a new Install
27
+ section for the published package; a "pip (from PyPI)" path on the
28
+ documentation landing page and in the API installation guide; the
29
+ automated tag-to-PyPI release chain in `CONTRIBUTING.md`; the `compare`
30
+ reference in the CLI guide and API pages.
31
+
32
+ ### Changed
33
+
34
+ - The walk-forward fold options (`--horizon`, `--initial-train`, `--step`,
35
+ `--gap`, `--window`) are declared once and shared by `backtest`,
36
+ `compare`, and `pipeline`, so the three commands cannot drift apart.
9
37
 
10
38
  ## [0.4.0] - 2026-12-02
11
39
 
@@ -19,5 +19,5 @@ keywords:
19
19
  - machine-learning
20
20
  license: MIT
21
21
  repository-code: "https://github.com/Abolfazlrwm/forecastforge"
22
- version: "0.4.0"
22
+ version: "0.5.0"
23
23
  date-released: "2026-12-02"
@@ -58,6 +58,14 @@ Release cadence:
58
58
  `vX.Y.Z` tag is created on the merge commit as part of the release
59
59
  process.
60
60
 
61
+ Pushing the tag runs the automated release chain: `release.yml` verifies
62
+ the tag against the package version, builds and smoke-tests the
63
+ distribution, and attaches it to the GitHub release, then hands off to
64
+ `pypi.yml`, which publishes to PyPI through the Trusted Publisher. A
65
+ release is therefore one annotated tag with no manual packaging or
66
+ upload step — the details, including the one-time PyPI setup and failure
67
+ handling, are in [docs/publishing.md](docs/publishing.md).
68
+
61
69
  ## Commit Convention
62
70
 
63
71
  ForecastForge follows [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: forecastforge
3
- Version: 0.4.0
3
+ Version: 0.5.0
4
4
  Summary: ForecastForge: an open-source time-series forecasting library with leakage-safe features, walk-forward evaluation, and a reproducible benchmark.
5
5
  Project-URL: Homepage, https://github.com/Abolfazlrwm/forecastforge
6
6
  Project-URL: Repository, https://github.com/Abolfazlrwm/forecastforge
@@ -55,10 +55,13 @@ Description-Content-Type: text/markdown
55
55
 
56
56
  # ForecastForge
57
57
 
58
+ [![PyPI - Version](https://img.shields.io/pypi/v/forecastforge)](https://pypi.org/project/forecastforge/)
59
+ [![PyPI - Python](https://img.shields.io/pypi/pyversions/forecastforge)](https://pypi.org/project/forecastforge/)
60
+ [![GitHub Release](https://img.shields.io/github/v/release/Abolfazlrwm/forecastforge)](https://github.com/Abolfazlrwm/forecastforge/releases/latest)
58
61
  [![CI](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/ci.yml/badge.svg)](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/ci.yml)
59
62
  [![Docs](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/docs.yml/badge.svg)](https://abolfazlrwm.github.io/forecastforge/)
63
+ [![CodeQL](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/security.yml/badge.svg)](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/security.yml)
60
64
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
61
- [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
62
65
  [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-261230.svg)](https://github.com/astral-sh/ruff)
63
66
  [![Checked with mypy](https://img.shields.io/badge/mypy-checked-2A6DB2.svg)](https://mypy-lang.org/)
64
67
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://www.conventionalcommits.org/en/v1.0.0/)
@@ -73,6 +76,29 @@ Description-Content-Type: text/markdown
73
76
  > forecaster interface with four baselines and three optional models, and a
74
77
  > walk-forward backtester with a reproducible benchmark.
75
78
 
79
+ ## Install
80
+
81
+ ForecastForge is on PyPI (Python 3.12+):
82
+
83
+ ```bash
84
+ pip install forecastforge
85
+ ```
86
+
87
+ Optional extras: `"forecastforge[data]"` adds the Yahoo Finance connector and
88
+ the Parquet engine, `"forecastforge[models]"` adds the ETS/ARIMA/LightGBM
89
+ forecasters, and `"forecastforge[viz]"` adds matplotlib for the demo figures.
90
+ To work on the code itself, clone the repository and install editable:
91
+
92
+ ```bash
93
+ git clone https://github.com/Abolfazlrwm/forecastforge.git
94
+ cd forecastforge
95
+ pip install -e ".[dev,viz]"
96
+ ```
97
+
98
+ The release chain is fully automated: an annotated `vX.Y.Z` tag builds the
99
+ distribution, attaches it to the GitHub release, and publishes it to PyPI —
100
+ see [docs/publishing.md](docs/publishing.md).
101
+
76
102
  ## Project Goals
77
103
 
78
104
  ForecastForge aims to be an open-source, production-grade platform for
@@ -487,13 +513,16 @@ forecastforge generate --symbol SPY --seed 2024 --length 504 --output data/raw/s
487
513
  forecastforge validate data/raw/spy.csv
488
514
  forecastforge features data/raw/spy.csv
489
515
  forecastforge backtest data/raw/spy.csv --horizon 5 --initial-train 252 --step 5 --gap 1
516
+ forecastforge compare data/raw/spy.csv --horizon 5 --initial-train 252 --step 5 --gap 1
490
517
  forecastforge forecast data/raw/spy.csv --horizon 5 --models naive,drift --output data/processed/spy_forecast.csv
491
518
  forecastforge pipeline --seed 3 --length 600 --initial-train 252 --models naive,drift
492
519
  ```
493
520
 
494
- `forecast` fits the chosen baselines on the file's full history and writes
495
- the steps ahead; a file with an irregular timestamp cadence is rejected
496
- rather than forecast against invented dates.
521
+ `compare` ranks the baselines against the same folds by a chosen metric
522
+ (`--metric`, default `mase`) and shows how each model's error grows with
523
+ the horizon step. `forecast` fits the chosen baselines on the file's full
524
+ history and writes the steps ahead; a file with an irregular timestamp
525
+ cadence is rejected rather than forecast against invented dates.
497
526
 
498
527
  The full option reference lives in [docs/cli.md](docs/cli.md) and on the
499
528
  [documentation site](https://abolfazlrwm.github.io/forecastforge/cli/).
@@ -1,9 +1,12 @@
1
1
  # ForecastForge
2
2
 
3
+ [![PyPI - Version](https://img.shields.io/pypi/v/forecastforge)](https://pypi.org/project/forecastforge/)
4
+ [![PyPI - Python](https://img.shields.io/pypi/pyversions/forecastforge)](https://pypi.org/project/forecastforge/)
5
+ [![GitHub Release](https://img.shields.io/github/v/release/Abolfazlrwm/forecastforge)](https://github.com/Abolfazlrwm/forecastforge/releases/latest)
3
6
  [![CI](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/ci.yml/badge.svg)](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/ci.yml)
4
7
  [![Docs](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/docs.yml/badge.svg)](https://abolfazlrwm.github.io/forecastforge/)
8
+ [![CodeQL](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/security.yml/badge.svg)](https://github.com/Abolfazlrwm/forecastforge/actions/workflows/security.yml)
5
9
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
6
- [![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](https://www.python.org/downloads/)
7
10
  [![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-261230.svg)](https://github.com/astral-sh/ruff)
8
11
  [![Checked with mypy](https://img.shields.io/badge/mypy-checked-2A6DB2.svg)](https://mypy-lang.org/)
9
12
  [![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://www.conventionalcommits.org/en/v1.0.0/)
@@ -18,6 +21,29 @@
18
21
  > forecaster interface with four baselines and three optional models, and a
19
22
  > walk-forward backtester with a reproducible benchmark.
20
23
 
24
+ ## Install
25
+
26
+ ForecastForge is on PyPI (Python 3.12+):
27
+
28
+ ```bash
29
+ pip install forecastforge
30
+ ```
31
+
32
+ Optional extras: `"forecastforge[data]"` adds the Yahoo Finance connector and
33
+ the Parquet engine, `"forecastforge[models]"` adds the ETS/ARIMA/LightGBM
34
+ forecasters, and `"forecastforge[viz]"` adds matplotlib for the demo figures.
35
+ To work on the code itself, clone the repository and install editable:
36
+
37
+ ```bash
38
+ git clone https://github.com/Abolfazlrwm/forecastforge.git
39
+ cd forecastforge
40
+ pip install -e ".[dev,viz]"
41
+ ```
42
+
43
+ The release chain is fully automated: an annotated `vX.Y.Z` tag builds the
44
+ distribution, attaches it to the GitHub release, and publishes it to PyPI —
45
+ see [docs/publishing.md](docs/publishing.md).
46
+
21
47
  ## Project Goals
22
48
 
23
49
  ForecastForge aims to be an open-source, production-grade platform for
@@ -432,13 +458,16 @@ forecastforge generate --symbol SPY --seed 2024 --length 504 --output data/raw/s
432
458
  forecastforge validate data/raw/spy.csv
433
459
  forecastforge features data/raw/spy.csv
434
460
  forecastforge backtest data/raw/spy.csv --horizon 5 --initial-train 252 --step 5 --gap 1
461
+ forecastforge compare data/raw/spy.csv --horizon 5 --initial-train 252 --step 5 --gap 1
435
462
  forecastforge forecast data/raw/spy.csv --horizon 5 --models naive,drift --output data/processed/spy_forecast.csv
436
463
  forecastforge pipeline --seed 3 --length 600 --initial-train 252 --models naive,drift
437
464
  ```
438
465
 
439
- `forecast` fits the chosen baselines on the file's full history and writes
440
- the steps ahead; a file with an irregular timestamp cadence is rejected
441
- rather than forecast against invented dates.
466
+ `compare` ranks the baselines against the same folds by a chosen metric
467
+ (`--metric`, default `mase`) and shows how each model's error grows with
468
+ the horizon step. `forecast` fits the chosen baselines on the file's full
469
+ history and writes the steps ahead; a file with an irregular timestamp
470
+ cadence is rejected rather than forecast against invented dates.
442
471
 
443
472
  The full option reference lives in [docs/cli.md](docs/cli.md) and on the
444
473
  [documentation site](https://abolfazlrwm.github.io/forecastforge/cli/).
@@ -0,0 +1 @@
1
+ 0.5.0
@@ -12,6 +12,10 @@ before its cutoff and scores predictions against targets strictly after it.
12
12
 
13
13
  ::: forecastforge.evaluation.backtest
14
14
 
15
+ ## Model comparison
16
+
17
+ ::: forecastforge.evaluation.compare
18
+
15
19
  ## Benchmark
16
20
 
17
21
  ::: forecastforge.evaluation.benchmark
@@ -19,10 +19,14 @@ placeholders for planned phases and intentionally have no public API yet.
19
19
  ## Install
20
20
 
21
21
  ```bash
22
- pip install -e . # core, fully offline
23
- pip install -e ".[data]" # + Yahoo Finance connector and Parquet engine
24
- pip install -e ".[models]" # + statsmodels and LightGBM forecasters
25
- pip install -e ".[viz]" # + matplotlib for the example figures
22
+ # From PyPI
23
+ pip install forecastforge # core, fully offline
24
+ pip install "forecastforge[data]" # + Yahoo Finance connector and Parquet engine
25
+ pip install "forecastforge[models]" # + statsmodels and LightGBM forecasters
26
+ pip install "forecastforge[viz]" # + matplotlib for the example figures
27
+
28
+ # From a repository checkout
29
+ pip install -e ".[dev,viz]" # everything needed to develop and run the demos
26
30
  ```
27
31
 
28
32
  The optional models import cleanly without their dependency and raise an
@@ -81,6 +81,44 @@ Key options: `--window N` switches from an expanding window to a rolling
81
81
  one, `--seasonal-period` sets the season lag used by `seasonal_naive` and
82
82
  the MASE scale, and `--ma-window` / `--drift-window` size those baselines.
83
83
 
84
+ ### `compare`
85
+
86
+ Backtests the chosen baselines against the same walk-forward folds and
87
+ prints the per-model comparison: the metrics table sorted best-first by
88
+ `--metric` (one of `mae`, `rmse`, `smape`, `mase`,
89
+ `directional_accuracy`; default `mase`), then the MAE of each model at
90
+ every horizon step pooled across folds — how far ahead of its origin each
91
+ model still holds its accuracy.
92
+
93
+ ```console
94
+ $ forecastforge compare data/raw/spy.csv --horizon 5 --initial-train 252 \
95
+ --step 5 --gap 1 --models naive,drift
96
+ series : 504 rows, 2015-01-02 to 2016-12-07
97
+ folds : 50 (horizon 5, step 5, gap 1, window expanding)
98
+
99
+ best : naive by mase
100
+
101
+ mae rmse smape mase directional_accuracy
102
+ naive 1.6716 2.1267 1.5083 0.8014 52.8
103
+ drift 1.6952 2.2182 1.5268 0.8132 53.2
104
+
105
+ MAE by horizon step (lower is better):
106
+ model naive drift
107
+ horizon
108
+ 1 1.4228 1.4484
109
+ 2 1.5754 1.6523
110
+ 3 1.7444 1.7222
111
+ 4 1.7710 1.7396
112
+ 5 1.8444 1.9134
113
+ ```
114
+
115
+ Every metric ranks ascending — a lower error is better — except
116
+ `directional_accuracy`, which ranks descending because a higher share of
117
+ correctly signed changes wins. `--output` writes the sorted ranking table
118
+ as `.csv` or `.parquet`. Unknown model names, unknown metrics, unreadable
119
+ files, and series too short for a fold exit `1` with an `error:` line on
120
+ stderr, like the other commands.
121
+
84
122
  ### `forecast`
85
123
 
86
124
  Fits the chosen baselines on the full history of a file and forecasts the
@@ -19,6 +19,14 @@ hand-computed values, and a benchmark that reports ties as ties.
19
19
 
20
20
  Every path below is fully offline and deterministic.
21
21
 
22
+ === "pip (from PyPI)"
23
+
24
+ ```bash
25
+ pip install forecastforge
26
+ forecastforge pipeline --seed 3 --length 600 \
27
+ --initial-train 252 --models naive,drift
28
+ ```
29
+
22
30
  === "pip (from a checkout)"
23
31
 
24
32
  ```bash
@@ -12,9 +12,18 @@ documents how the PyPI leg works and the one-time setup it requires.
12
12
  wheel imports and reports the tagged version in a clean virtual
13
13
  environment, generates `SHA256SUMS`, and attaches everything to the
14
14
  GitHub release with notes extracted from `CHANGELOG.md`.
15
- 3. Publishing the release triggers `.github/workflows/pypi.yml`, which
16
- rebuilds the distribution, smoke-tests the wheel again, and uploads it
17
- to PyPI.
15
+ 3. When the release workflow completes successfully, it hands off to
16
+ `.github/workflows/pypi.yml`, which checks out the same tag, rebuilds
17
+ the distribution, smoke-tests the wheel again, and uploads it to PyPI.
18
+
19
+ The handoff watches the Release workflow's completion rather than the
20
+ release event itself: the release is created with the default
21
+ GITHUB_TOKEN, and GitHub does not fire workflow events for actions
22
+ taken by GITHUB_TOKEN, so a `release: published` trigger would never
23
+ run. A maintainer can also publish (or re-publish) an existing tag by
24
+ dispatching the PyPI workflow from the Actions tab with the tag as the
25
+ ref — useful after fixing a Trusted Publisher record that rejected the
26
+ first attempt.
18
27
 
19
28
  The PyPI job authenticates with OpenID Connect, not a stored secret: the
20
29
  workflow mints a short-lived token, and PyPI validates it against the
@@ -79,5 +88,6 @@ The publish job fails loudly rather than guessing:
79
88
  anything is built.
80
89
  - If PyPI rejects the OIDC token (Trusted Publisher not configured, or the
81
90
  environment name changed), the publish job fails at the OIDC step and no
82
- upload happens. Fix the publisher record and re-run the failed jobs from
83
- the Actions tab — the release does not need to be recreated.
91
+ upload happens. Fix the publisher record and publish again by dispatching
92
+ the PyPI workflow with the tag as the ref — the release does not need to
93
+ be recreated, and PyPI treats the retried upload as the same version.
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "forecastforge"
7
- version = "0.4.0"
7
+ version = "0.5.0"
8
8
  description = "ForecastForge: an open-source time-series forecasting library with leakage-safe features, walk-forward evaluation, and a reproducible benchmark."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.12"
@@ -18,7 +18,7 @@ Implemented:
18
18
  benchmark.
19
19
  * Orchestration: a seed-to-backtest ``pipelines`` module and the
20
20
  ``forecastforge`` console script (``info``, ``validate``, ``generate``,
21
- ``features``, ``backtest``, ``pipeline``).
21
+ ``features``, ``backtest``, ``compare``, ``forecast``, ``pipeline``).
22
22
 
23
23
  Still planned:
24
24
  * Experiment tracking, serving, monitoring, and containerised deployment.
@@ -39,7 +39,12 @@ from forecastforge.data import (
39
39
  write_csv,
40
40
  write_parquet,
41
41
  )
42
- from forecastforge.evaluation import BacktestConfig, WalkForwardBacktester
42
+ from forecastforge.evaluation import (
43
+ BacktestConfig,
44
+ WalkForwardBacktester,
45
+ mae_by_step,
46
+ rank_models,
47
+ )
43
48
  from forecastforge.features import (
44
49
  MACD,
45
50
  RSI,
@@ -257,6 +262,47 @@ def _cmd_backtest(args: argparse.Namespace) -> int:
257
262
  return 0
258
263
 
259
264
 
265
+ def _cmd_compare(args: argparse.Namespace) -> int:
266
+ """Backtest the baselines and report the per-model comparison."""
267
+ series = _load_series(Path(args.path), args.target)
268
+ models = build_models(
269
+ _split_models(args.models),
270
+ args.horizon,
271
+ seasonal_period=args.seasonal_period,
272
+ moving_average_window=args.ma_window,
273
+ drift_window=args.drift_window,
274
+ )
275
+ backtester = WalkForwardBacktester(
276
+ BacktestConfig(
277
+ horizon=args.horizon,
278
+ initial_train=args.initial_train,
279
+ step=args.step,
280
+ gap=args.gap,
281
+ window=args.window,
282
+ seasonal_period=args.seasonal_period,
283
+ )
284
+ )
285
+ result = backtester.run(series.target_series, models)
286
+ ranked = rank_models(result, metric=args.metric)
287
+ _emit(f"series : {len(series)} rows, {series.index[0].date()} to {series.index[-1].date()}")
288
+ _emit(
289
+ f"folds : {len(result.folds)} (horizon {args.horizon}, step {args.step}, "
290
+ f"gap {args.gap}, window {args.window or 'expanding'})"
291
+ )
292
+ _emit("")
293
+ _emit(f"best : {ranked.index[0]} by {args.metric}")
294
+ _emit("")
295
+ _emit(ranked.round(4).to_string())
296
+ _emit("")
297
+ _emit("MAE by horizon step (lower is better):")
298
+ _emit(mae_by_step(result).round(4).to_string())
299
+ if args.output:
300
+ ranked = ranked.rename_axis("model")
301
+ _write_frame(ranked, Path(args.output))
302
+ _emit(f"ranking written to {args.output}")
303
+ return 0
304
+
305
+
260
306
  def _cmd_forecast(args: argparse.Namespace) -> int:
261
307
  """Fit the baselines on the full history and forecast the next steps."""
262
308
  series = _load_series(Path(args.path), args.target)
@@ -331,12 +377,32 @@ def _add_file_options(parser: argparse.ArgumentParser) -> None:
331
377
  parser.add_argument("--target", default="close", help="column to forecast (default: close)")
332
378
 
333
379
 
380
+ def _add_fold_options(parser: argparse.ArgumentParser) -> None:
381
+ """Add the walk-forward fold layout shared by the backtesting commands.
382
+
383
+ ``backtest``, ``compare``, and ``pipeline`` all describe their folds with
384
+ the same five numbers, so they are declared once here instead of drifting
385
+ apart in three copies.
386
+ """
387
+ parser.add_argument("--horizon", type=int, default=1, help="rows forecast per origin")
388
+ parser.add_argument(
389
+ "--initial-train",
390
+ type=int,
391
+ default=252,
392
+ dest="initial_train",
393
+ help="rows before the first origin",
394
+ )
395
+ parser.add_argument("--step", type=int, default=1, help="rows between origins")
396
+ parser.add_argument("--gap", type=int, default=0, help="embargoed rows per fold")
397
+ parser.add_argument("--window", type=int, default=None, help="rolling window length")
398
+
399
+
334
400
  def _add_baseline_options(parser: argparse.ArgumentParser) -> None:
335
401
  """Add the shared baseline-model options to a subparser.
336
402
 
337
- ``backtest``, ``forecast``, and ``pipeline`` all drive the same baseline
338
- factory (see ``build_models``), so their model options are declared once
339
- here instead of drifting apart in three copies.
403
+ ``backtest``, ``compare``, ``forecast``, and ``pipeline`` all drive the
404
+ same baseline factory (see ``build_models``), so their model options are
405
+ declared once here instead of drifting apart in four copies.
340
406
  """
341
407
  parser.add_argument(
342
408
  "--models",
@@ -373,7 +439,7 @@ def build_parser() -> argparse.ArgumentParser:
373
439
  description=(
374
440
  "Offline time-series forecasting utilities: validate data, generate "
375
441
  "deterministic synthetic series, engineer features, backtest baselines, "
376
- "and forecast the steps ahead."
442
+ "compare them by metric, and forecast the steps ahead."
377
443
  ),
378
444
  )
379
445
  parser.add_argument(
@@ -413,20 +479,27 @@ def build_parser() -> argparse.ArgumentParser:
413
479
  "backtest", help="walk-forward backtest the baselines over a file"
414
480
  )
415
481
  _add_file_options(backtest)
416
- backtest.add_argument("--horizon", type=int, default=1, help="rows forecast per origin")
417
- backtest.add_argument(
418
- "--initial-train",
419
- type=int,
420
- default=252,
421
- dest="initial_train",
422
- help="rows before the first origin",
423
- )
424
- backtest.add_argument("--step", type=int, default=1, help="rows between origins")
425
- backtest.add_argument("--gap", type=int, default=0, help="embargoed rows per fold")
426
- backtest.add_argument("--window", type=int, default=None, help="rolling window length")
482
+ _add_fold_options(backtest)
427
483
  _add_baseline_options(backtest)
428
484
  backtest.set_defaults(handler=_cmd_backtest)
429
485
 
486
+ compare = subparsers.add_parser(
487
+ "compare", help="backtest the baselines and rank them by a metric"
488
+ )
489
+ _add_file_options(compare)
490
+ _add_fold_options(compare)
491
+ _add_baseline_options(compare)
492
+ compare.add_argument(
493
+ "--metric",
494
+ default="mase",
495
+ help="ranking metric: mae, rmse, smape, mase, directional_accuracy",
496
+ )
497
+ compare.add_argument(
498
+ "--output",
499
+ help="write the ranking table to this file (.csv or .parquet)",
500
+ )
501
+ compare.set_defaults(handler=_cmd_compare)
502
+
430
503
  forecast = subparsers.add_parser(
431
504
  "forecast", help="fit the baselines on a file and forecast the next steps"
432
505
  )
@@ -445,11 +518,7 @@ def build_parser() -> argparse.ArgumentParser:
445
518
  pipeline.add_argument("--symbol", default="SPY")
446
519
  pipeline.add_argument("--seed", type=int, default=42)
447
520
  pipeline.add_argument("--length", type=int, default=504)
448
- pipeline.add_argument("--horizon", type=int, default=1)
449
- pipeline.add_argument("--initial-train", type=int, default=252, dest="initial_train")
450
- pipeline.add_argument("--step", type=int, default=1)
451
- pipeline.add_argument("--gap", type=int, default=0)
452
- pipeline.add_argument("--window", type=int, default=None)
521
+ _add_fold_options(pipeline)
453
522
  _add_baseline_options(pipeline)
454
523
  pipeline.set_defaults(handler=_cmd_pipeline)
455
524
 
@@ -5,6 +5,8 @@
5
5
  * :mod:`forecastforge.evaluation.backtest` — the leakage-safe walk-forward
6
6
  backtester that produces the tidy prediction frame every report is built
7
7
  from.
8
+ * :mod:`forecastforge.evaluation.compare` — best-first model ranking by a
9
+ chosen metric and per-horizon-step error tables, built on that frame.
8
10
  """
9
11
 
10
12
  from __future__ import annotations
@@ -15,6 +17,7 @@ from forecastforge.evaluation.backtest import (
15
17
  Fold,
16
18
  WalkForwardBacktester,
17
19
  )
20
+ from forecastforge.evaluation.compare import METRICS, mae_by_step, rank_models
18
21
  from forecastforge.evaluation.metrics import (
19
22
  MetricSet,
20
23
  directional_accuracy,
@@ -28,6 +31,7 @@ from forecastforge.evaluation.metrics import (
28
31
  )
29
32
 
30
33
  __all__ = [
34
+ "METRICS",
31
35
  "BacktestConfig",
32
36
  "BacktestResult",
33
37
  "Fold",
@@ -37,8 +41,10 @@ __all__ = [
37
41
  "evaluate",
38
42
  "interval_coverage",
39
43
  "mae",
44
+ "mae_by_step",
40
45
  "mase",
41
46
  "mase_scale",
47
+ "rank_models",
42
48
  "rmse",
43
49
  "smape",
44
50
  ]