sporacast 0.2.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 (61) hide show
  1. sporacast-0.2.0/.gitignore +15 -0
  2. sporacast-0.2.0/LICENSE +201 -0
  3. sporacast-0.2.0/NOTICE +8 -0
  4. sporacast-0.2.0/PKG-INFO +99 -0
  5. sporacast-0.2.0/README.md +70 -0
  6. sporacast-0.2.0/docs/api.md +196 -0
  7. sporacast-0.2.0/docs/methods.md +173 -0
  8. sporacast-0.2.0/examples/intermittent_panel.py +59 -0
  9. sporacast-0.2.0/pyproject.toml +53 -0
  10. sporacast-0.2.0/src/sporacast/__init__.py +18 -0
  11. sporacast-0.2.0/src/sporacast/_calibration.py +43 -0
  12. sporacast-0.2.0/src/sporacast/_core/__init__.py +1 -0
  13. sporacast-0.2.0/src/sporacast/_core/backend.py +176 -0
  14. sporacast-0.2.0/src/sporacast/_core/bagged_quantiles.py +356 -0
  15. sporacast-0.2.0/src/sporacast/_core/count_calibration.py +189 -0
  16. sporacast-0.2.0/src/sporacast/_core/empirical.py +41 -0
  17. sporacast-0.2.0/src/sporacast/_core/engine.py +513 -0
  18. sporacast-0.2.0/src/sporacast/_core/feature_plan.py +99 -0
  19. sporacast-0.2.0/src/sporacast/_core/features.py +392 -0
  20. sporacast-0.2.0/src/sporacast/_core/hurdle.py +301 -0
  21. sporacast-0.2.0/src/sporacast/_core/issued_features.py +69 -0
  22. sporacast-0.2.0/src/sporacast/_core/issued_history.py +226 -0
  23. sporacast-0.2.0/src/sporacast/_core/issued_quantiles.py +452 -0
  24. sporacast-0.2.0/src/sporacast/_core/local_hurdle.py +95 -0
  25. sporacast-0.2.0/src/sporacast/_core/lower_tail.py +218 -0
  26. sporacast-0.2.0/src/sporacast/_core/lower_weights.py +266 -0
  27. sporacast-0.2.0/src/sporacast/_core/occurrence.py +368 -0
  28. sporacast-0.2.0/src/sporacast/_core/parent_law.py +379 -0
  29. sporacast-0.2.0/src/sporacast/_core/point_actions.py +42 -0
  30. sporacast-0.2.0/src/sporacast/_core/positive_cdf.py +687 -0
  31. sporacast-0.2.0/src/sporacast/_core/profile.py +357 -0
  32. sporacast-0.2.0/src/sporacast/_core/profile_blend.py +435 -0
  33. sporacast-0.2.0/src/sporacast/_core/profile_endpoint.py +244 -0
  34. sporacast-0.2.0/src/sporacast/_core/profile_policy.py +390 -0
  35. sporacast-0.2.0/src/sporacast/_core/selection_math.py +92 -0
  36. sporacast-0.2.0/src/sporacast/_core/severity.py +374 -0
  37. sporacast-0.2.0/src/sporacast/_core/singleton.py +657 -0
  38. sporacast-0.2.0/src/sporacast/_core/statistical_bank.py +413 -0
  39. sporacast-0.2.0/src/sporacast/_core/upper_calibration.py +72 -0
  40. sporacast-0.2.0/src/sporacast/_core/worker.py +80 -0
  41. sporacast-0.2.0/src/sporacast/_direct.py +330 -0
  42. sporacast-0.2.0/src/sporacast/data.py +312 -0
  43. sporacast-0.2.0/src/sporacast/evaluation.py +259 -0
  44. sporacast-0.2.0/src/sporacast/forecaster.py +1131 -0
  45. sporacast-0.2.0/src/sporacast/persistence.py +102 -0
  46. sporacast-0.2.0/src/sporacast/profile.py +204 -0
  47. sporacast-0.2.0/src/sporacast/selection.py +28 -0
  48. sporacast-0.2.0/src/sporacast/validation.py +130 -0
  49. sporacast-0.2.0/tests/test_core_backend.py +76 -0
  50. sporacast-0.2.0/tests/test_core_engine.py +307 -0
  51. sporacast-0.2.0/tests/test_core_math.py +260 -0
  52. sporacast-0.2.0/tests/test_data.py +134 -0
  53. sporacast-0.2.0/tests/test_direct.py +121 -0
  54. sporacast-0.2.0/tests/test_evaluation.py +129 -0
  55. sporacast-0.2.0/tests/test_forecaster.py +114 -0
  56. sporacast-0.2.0/tests/test_forecaster_validation.py +885 -0
  57. sporacast-0.2.0/tests/test_persistence.py +15 -0
  58. sporacast-0.2.0/tests/test_persistence_edges.py +81 -0
  59. sporacast-0.2.0/tests/test_profile.py +92 -0
  60. sporacast-0.2.0/tests/test_selection.py +15 -0
  61. sporacast-0.2.0/tests/test_validation.py +91 -0
@@ -0,0 +1,15 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .venv/
6
+ build/
7
+ dist/
8
+ *.egg-info/
9
+ .coverage
10
+ htmlcov/
11
+ .env
12
+ *.whl
13
+ *.npz
14
+ *.parquet
15
+ *.zip
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
sporacast-0.2.0/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ Sporacast
2
+ Copyright holders retain the rights in their contributions.
3
+
4
+ This distribution is licensed under the Apache License, Version 2.0.
5
+ It does not bundle LightGBM, NumPy, SciPy, Pandas or Polars; those dependencies
6
+ retain their own licenses. No pretrained models or datasets are included.
7
+
8
+ Methods and mathematical references are described in docs/methods.md.
@@ -0,0 +1,99 @@
1
+ Metadata-Version: 2.4
2
+ Name: sporacast
3
+ Version: 0.2.0
4
+ Summary: Profile-guided forecasting for intermittent panels
5
+ Project-URL: Repository, https://github.com/AbishekSriramulu/sporacast
6
+ Project-URL: Documentation, https://github.com/AbishekSriramulu/sporacast#readme
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ License-File: NOTICE
10
+ Keywords: automl,forecasting,intermittent-demand,time-series
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: <3.13,>=3.11
18
+ Requires-Dist: lightgbm==4.6.0
19
+ Requires-Dist: numpy==1.26.4
20
+ Requires-Dist: pandas==2.1.4
21
+ Requires-Dist: polars==1.44.1
22
+ Requires-Dist: scipy==1.15.3
23
+ Provides-Extra: dev
24
+ Requires-Dist: build<2,>=1.3; extra == 'dev'
25
+ Requires-Dist: pytest<10,>=8.3; extra == 'dev'
26
+ Requires-Dist: ruff<1,>=0.12; extra == 'dev'
27
+ Requires-Dist: twine<7,>=6; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # Sporacast
31
+
32
+ Profile-guided forecasting for intermittent panels of nonnegative time series.
33
+
34
+ Sporacast measures a training panel, admits supported forecasting recipes,
35
+ selects a base system on earlier validation origins, and evaluates corrections
36
+ on forecasts actually issued at later validation origins. You can inspect the
37
+ profile, candidate space, selection evidence and update policy.
38
+
39
+ ## Install
40
+
41
+ Sporacast supports Python 3.11 and 3.12.
42
+
43
+ ```sh
44
+ python -m pip install sporacast
45
+ ```
46
+
47
+ ## Use
48
+
49
+ ```python
50
+ from sporacast import Sporacast
51
+
52
+ # train and validation: Pandas or Polars frames with unique_id, ds and y.
53
+ model = Sporacast(
54
+ freq="D",
55
+ horizon=7,
56
+ metric="mase",
57
+ )
58
+ print(model.search_space(train))
59
+ model.fit(train, validation=validation)
60
+ forecast = model.predict()
61
+ print(model.selected_recipe())
62
+ print(model.explain())
63
+ ```
64
+
65
+ Choose the metric you want to optimize. Common choices are `mase`, `rmsse` and
66
+ `scaled_crps9`; `crps9` is the unscaled quantile score. Recipe selection remains
67
+ automatic. For custom scaling, seasonal denominators or aggregation, pass an
68
+ `Evaluation` contract instead of `metric`.
69
+ Version one supports these three metric families. Additional built-in losses
70
+ and user-defined metrics are reserved for later versions.
71
+
72
+ `point` is the selected point action. `q10` through `q90` are ordered deciles.
73
+ The mean of these nine values is not an identified full-distribution mean.
74
+ Without validation, the simplest supported control is used and the report says
75
+ that no validation selection took place.
76
+
77
+ For source publication delays or overlapping origins, provide an explicit
78
+ `ValidationPlan`; timestamp labels alone do not prove availability.
79
+
80
+ Static, historical and future-known covariates are declared using `Covariates`.
81
+ Future-known values must be supplied for every requested future row. Categorical
82
+ statistics use only the observations available at each training issuance.
83
+ The count-distribution recipe is target-only; covariates select a compatible
84
+ direct-tree recipe instead of being silently discarded.
85
+
86
+ Run `python examples/intermittent_panel.py` for the synthetic target-only
87
+ example, or add `--covariates` for static categories, a historical numeric
88
+ signal and a known-future category in the same example.
89
+
90
+ The default LightGBM dependency is 4.6.0. The residual/bag recipe additionally
91
+ requires an explicitly declared isolated 4.7.0 fitting runtime. It is excluded
92
+ with an explanation when that runtime is absent. No runtime is downloaded or
93
+ installed by forecasting calls.
94
+
95
+ ## Guides
96
+
97
+ - [API and data contracts](https://github.com/AbishekSriramulu/sporacast/blob/main/docs/api.md)
98
+ - [How Sporacast forecasts](https://github.com/AbishekSriramulu/sporacast/blob/main/docs/methods.md)
99
+ - [Target-only and covariate examples](https://github.com/AbishekSriramulu/sporacast/blob/main/examples/intermittent_panel.py)
@@ -0,0 +1,70 @@
1
+ # Sporacast
2
+
3
+ Profile-guided forecasting for intermittent panels of nonnegative time series.
4
+
5
+ Sporacast measures a training panel, admits supported forecasting recipes,
6
+ selects a base system on earlier validation origins, and evaluates corrections
7
+ on forecasts actually issued at later validation origins. You can inspect the
8
+ profile, candidate space, selection evidence and update policy.
9
+
10
+ ## Install
11
+
12
+ Sporacast supports Python 3.11 and 3.12.
13
+
14
+ ```sh
15
+ python -m pip install sporacast
16
+ ```
17
+
18
+ ## Use
19
+
20
+ ```python
21
+ from sporacast import Sporacast
22
+
23
+ # train and validation: Pandas or Polars frames with unique_id, ds and y.
24
+ model = Sporacast(
25
+ freq="D",
26
+ horizon=7,
27
+ metric="mase",
28
+ )
29
+ print(model.search_space(train))
30
+ model.fit(train, validation=validation)
31
+ forecast = model.predict()
32
+ print(model.selected_recipe())
33
+ print(model.explain())
34
+ ```
35
+
36
+ Choose the metric you want to optimize. Common choices are `mase`, `rmsse` and
37
+ `scaled_crps9`; `crps9` is the unscaled quantile score. Recipe selection remains
38
+ automatic. For custom scaling, seasonal denominators or aggregation, pass an
39
+ `Evaluation` contract instead of `metric`.
40
+ Version one supports these three metric families. Additional built-in losses
41
+ and user-defined metrics are reserved for later versions.
42
+
43
+ `point` is the selected point action. `q10` through `q90` are ordered deciles.
44
+ The mean of these nine values is not an identified full-distribution mean.
45
+ Without validation, the simplest supported control is used and the report says
46
+ that no validation selection took place.
47
+
48
+ For source publication delays or overlapping origins, provide an explicit
49
+ `ValidationPlan`; timestamp labels alone do not prove availability.
50
+
51
+ Static, historical and future-known covariates are declared using `Covariates`.
52
+ Future-known values must be supplied for every requested future row. Categorical
53
+ statistics use only the observations available at each training issuance.
54
+ The count-distribution recipe is target-only; covariates select a compatible
55
+ direct-tree recipe instead of being silently discarded.
56
+
57
+ Run `python examples/intermittent_panel.py` for the synthetic target-only
58
+ example, or add `--covariates` for static categories, a historical numeric
59
+ signal and a known-future category in the same example.
60
+
61
+ The default LightGBM dependency is 4.6.0. The residual/bag recipe additionally
62
+ requires an explicitly declared isolated 4.7.0 fitting runtime. It is excluded
63
+ with an explanation when that runtime is absent. No runtime is downloaded or
64
+ installed by forecasting calls.
65
+
66
+ ## Guides
67
+
68
+ - [API and data contracts](https://github.com/AbishekSriramulu/sporacast/blob/main/docs/api.md)
69
+ - [How Sporacast forecasts](https://github.com/AbishekSriramulu/sporacast/blob/main/docs/methods.md)
70
+ - [Target-only and covariate examples](https://github.com/AbishekSriramulu/sporacast/blob/main/examples/intermittent_panel.py)
@@ -0,0 +1,196 @@
1
+ # API and data contracts
2
+
3
+ ## Data
4
+
5
+ Use a Polars or Pandas frame with one row per series and timestamp. Defaults are
6
+ `unique_id`, `ds`, `y`; constructor arguments can rename all three. Declare every
7
+ additional column through `Covariates(static=..., historical=..., future=...)`.
8
+ The roles are disjoint. Static values are constant within a series. Historical
9
+ covariates are used at their observed past timestamps; future-known covariates
10
+ also require values at every forecast timestamp.
11
+ Covariate keys and automatically constructed validation plans retain
12
+ nanosecond precision in Pandas and Polars inputs. Timezone-aware labels
13
+ are interpreted as UTC instants.
14
+
15
+ The time grid is regular. Duplicates, negative/infinite targets, interior
16
+ missing observations and incomplete trailing observations are errors. Leading
17
+ unknown observations remain missing. Observed zeros are observations, not
18
+ missing-value placeholders. A target-only count law requires integer counts;
19
+ nonnegative continuous data use compatible general recipes.
20
+
21
+ `history_window=None` retains the supplied history. An explicit positive
22
+ `history_window` declares a common source-retention limit for every recipe and
23
+ its training scale, rather than a model-specific fitting-window override.
24
+ Forecast updates verify immutable overlap before rolling that source window.
25
+
26
+ Names identify schema and axes. Their linguistic meaning does not select a
27
+ recipe. Categorical statistics pool lawful past observations and shrink toward
28
+ the corresponding past global mean. Unseen categories use that global fallback.
29
+
30
+ ## Construction and inspection
31
+
32
+ ```python
33
+ from sporacast import Covariates, Evaluation, Sporacast
34
+
35
+ model = Sporacast(
36
+ freq="D", horizon=7,
37
+ metric="rmsse",
38
+ covariates=Covariates(),
39
+ lags="auto", # or an explicit tuple of positive observed lags
40
+ num_threads=4, seed=0,
41
+ )
42
+ space = model.search_space(train)
43
+ model.fit(train, validation=validation)
44
+ forecast = model.predict()
45
+ ```
46
+
47
+ `search_space(train)` reports eligibility and reasons. It does not train models.
48
+ Calling it after fitting cannot change the fitted profile or selected policy.
49
+ `profile_report()`, `validation_results(stage="v1")`,
50
+ `validation_results(stage="v2")`, `selected_recipe()`, `explain()` and
51
+ `runtime_report()` return detached descriptions.
52
+
53
+ For a count-law family, `selected_recipe()` distinguishes the V1 law variant
54
+ from the effective variant selected on V2. The family, feature plan and point
55
+ readout remain the V1 choices. These are within-family alternatives already
56
+ produced from mature issued history, not additional model-family trials.
57
+
58
+ For supported target-only count panels, CRPS9-family selection can also compare
59
+ the standalone `hurdle:q50` producer. Its `requires_v2` flag is visible in the
60
+ candidate report. If it wins V1, `selected_recipe()["v1_finalists"]` lists it
61
+ first and the best other V1 recipe second. V2 compares the raw identity forecast
62
+ with that other recipe's complete existing correction menu, retaining existing
63
+ controls on ties. `recipe`, `correction` and `law_variant` identify the actual
64
+ final producer. Validation results label raw forecasts with their own recipe
65
+ and identity, rather than claiming a parent residual was fitted to them.
66
+
67
+ The standalone producer cannot be selected without V2, or from fewer than three
68
+ mature V2 origins. It must improve in two chronological V2 blocks as well as
69
+ aggregate loss. If support or evidence is insufficient, the other finalist's
70
+ policy remains. A selected raw producer needs no residual backend for updates.
71
+
72
+ With no validation the simplest supported control is used. The report states
73
+ that selection was profile-only. Validation is required to learn a preference
74
+ among the admitted alternatives.
75
+
76
+ ## Evaluation
77
+
78
+ The simple constructor accepts `metric="mase"`, `"rmsse"`, `"crps9"` or
79
+ `"scaled_crps9"`. MASE and RMSSE use their lag-one training-naive scales, with
80
+ undefined scales excluded; no arbitrary denominator floor is added. `crps9`
81
+ uses target units. `scaled_crps9` divides by the training activity mean with a
82
+ one-event floor. Version one supports these three metric families. WAPE, MSE,
83
+ MAE and custom objectives are reserved for a later version.
84
+
85
+ These names define losses, not fixed recipes or a mean/median router. To change
86
+ the seasonal lag, floor, scale or reduction, use an explicit contract, for
87
+ example `evaluation=Evaluation(metric="mase", seasonal_lag=7, floor=0.01)`.
88
+ Supplying both `metric` and `evaluation` is an error. Omitting both keeps the
89
+ default RMSSE contract.
90
+
91
+ `Evaluation` takes `metric`, `scale`, `seasonal_lag`, `floor`, `aggregation` and
92
+ `undefined_scale`. Metrics are `rmsse`, `mase`, `crps9`; scales are
93
+ `naive`, `activity`, `none`. Scaling is derived from the complete designated
94
+ historical prefix for each issue, independently of the fitted recipe.
95
+
96
+ For RMSSE the square root is taken inside each series-origin case, after its
97
+ lead-mean squared error. The case scores are then aggregated. This differs from
98
+ taking a final square root after averaging scaled squared errors.
99
+
100
+ CRPS9 uses correctly oriented pinball loss at deciles 0.1 through 0.9, with the
101
+ factor two and lead/quantile averages. It is a finite-grid approximation, not an
102
+ identified full-distribution CRPS. Set `scale="activity", floor=1` for a
103
+ training-activity normalization with a one-unit floor.
104
+
105
+ Optional `groups`, `zero_reference`, `reference_quantile` and `reference_floor`
106
+ describe a serializable evaluation reducer. They are evaluation metadata, never
107
+ features or routing categories. Group medians, Zero normalization and final
108
+ medians change the score's incentives; a score using them should not be described
109
+ as an additive proper scoring rule. Comparator-dependent average ranks are
110
+ external evaluation reports, not a fitting loss.
111
+
112
+ Undefined scales are excluded by one model-independent rule or rejected when
113
+ `undefined_scale="raise"`. A candidate cannot improve its result by omitting
114
+ forecasts or choosing different eligibility masks.
115
+
116
+ ## Explicit validation clocks
117
+
118
+ `ValidationPlan(v1=(...), v2=(...))` contains `ValidationOrigin` records with
119
+ `train_end`, `issue_at`, `target_available_at`, and optional `received_at`.
120
+ All explicit clocks are timezone-aware. `train_end` is an observation label,
121
+ not proof that an outcome was published. The default receipt is the declared
122
+ availability time.
123
+
124
+ The convenience split in `fit(..., validation=...)` uses consecutive horizon
125
+ windows and divides them chronologically into V1/V2. `source_timing="timestamp"`
126
+ means labels are observation instants. `source_timing="period_end"` means an
127
+ observation becomes known at the following grid label. Publication delays need
128
+ explicit origins and, when needed, `fit(..., information_times=...)`, a vector
129
+ covering every combined training/validation timestamp.
130
+
131
+ A partial trailing validation window is not scored; its dates appear in
132
+ `explain()["validation_plan"]["unscored_dates"]`. Those observations can still
133
+ enter final fitting once available. Explicit plans may describe supported
134
+ overlapping horizons.
135
+
136
+ Whole-path losses influence fitting policies only when availability is strictly
137
+ earlier than the next issue and the outcome has been received. An explicitly
138
+ declared raw observation may be known at issuance itself. Prefix validation
139
+ checks both source information clocks and earlier validation receipts. If a
140
+ delayed observation creates an unsupported gap, fitting raises instead of
141
+ inventing a zero or moving a clock. Final fitting also requires the included
142
+ validation outcomes to have matured.
143
+
144
+ V1 fixes the base or the explicitly reported pair of finalists. V2 evaluates
145
+ their permitted complete alternatives/readouts/calibration prequentially,
146
+ including warmups. Final coefficients are never replayed backwards over
147
+ validation. No test-target argument exists.
148
+
149
+ `fit(..., forecast_observer=callback)` optionally sends detached validation
150
+ forecasts and their issuance metadata to a local observer. No actual target is
151
+ included and return values are ignored. Observer errors abort fitting instead
152
+ of changing candidate eligibility. This allows an external evaluation script
153
+ to save issued forecasts without putting benchmark code or artifact storage
154
+ inside the library.
155
+
156
+ ## Updates and persistence
157
+
158
+ `update(observations, issue_at=...)` appends observations and refits the selected
159
+ policy's parameters. It does not choose a new recipe or tune correction
160
+ coefficients using deployment outcomes. Repeating identical observations is
161
+ idempotent; revisions and incomplete appends are rejected.
162
+ If an update first supplies explicit `information_times`, previous observations
163
+ retain their original timing convention and every later append must provide its
164
+ new source times. New times are never silently ignored.
165
+
166
+ ```python
167
+ model.save("/path/outside/the/source/model")
168
+ restored = Sporacast.load("/path/outside/the/source/model")
169
+ ```
170
+
171
+ States contain explicit JSON, numeric arrays and native tree text, never pickle.
172
+ Runtime executables are not embedded. Loading a residual/bag model for further
173
+ fitting requires the corresponding declared runtime. The stored current
174
+ forecast can be read without refitting.
175
+
176
+ ## Numerical runtime boundary
177
+
178
+ The statistical/direct fitting runtime uses LightGBM 4.6.0. Residual quantile
179
+ and bag fits use an isolated LightGBM 4.7.0 runtime supplied explicitly through
180
+ `residual_backend`. Fitting calls never install or download a runtime. The
181
+ library excludes unavailable numerical capabilities with an explanation.
182
+
183
+ For residual/bag recipes, create a second environment with the same pinned
184
+ NumPy/Pandas/Polars/SciPy versions as `pyproject.toml`, and LightGBM4.7.0 instead
185
+ of4.6.0. The worker receives this installed package's source explicitly; do not
186
+ install a conflicting second copy of Sporacast into that runtime.
187
+
188
+ ```python
189
+ from sporacast import ResidualBackend
190
+
191
+ backend = ResidualBackend("/path/to/residual-environment/bin/python")
192
+ model = Sporacast(freq="D", horizon=7, residual_backend=backend)
193
+ ```
194
+
195
+ Exact model text or floating-point predictions across different dependency
196
+ versions, operating systems and hardware are not assumed interchangeable.