awen-dlmax 0.1.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.
- awen_dlmax-0.1.0/LICENSE +201 -0
- awen_dlmax-0.1.0/NOTICE +13 -0
- awen_dlmax-0.1.0/PKG-INFO +265 -0
- awen_dlmax-0.1.0/README.md +225 -0
- awen_dlmax-0.1.0/pyproject.toml +88 -0
- awen_dlmax-0.1.0/setup.cfg +4 -0
- awen_dlmax-0.1.0/src/DLMAX/__init__.py +79 -0
- awen_dlmax-0.1.0/src/DLMAX/data/airline_passengers.csv +145 -0
- awen_dlmax-0.1.0/src/DLMAX/datasets.py +84 -0
- awen_dlmax-0.1.0/src/DLMAX/dlm_core.py +3338 -0
- awen_dlmax-0.1.0/src/DLMAX/dma.py +170 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/__init__.py +32 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/block.py +119 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/component_block.py +79 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/devices.py +144 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/discount_grid.py +1603 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/dlm_builder.py +1708 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/factories.py +487 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/grid_block.py +787 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/predictive.py +278 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/static_block.py +168 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/sweep.py +104 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs/universe.py +60 -0
- awen_dlmax-0.1.0/src/DLMAX/ffs_core.py +7859 -0
- awen_dlmax-0.1.0/src/DLMAX/smoother.py +354 -0
- awen_dlmax-0.1.0/src/awen_dlmax.egg-info/PKG-INFO +265 -0
- awen_dlmax-0.1.0/src/awen_dlmax.egg-info/SOURCES.txt +82 -0
- awen_dlmax-0.1.0/src/awen_dlmax.egg-info/dependency_links.txt +1 -0
- awen_dlmax-0.1.0/src/awen_dlmax.egg-info/requires.txt +22 -0
- awen_dlmax-0.1.0/src/awen_dlmax.egg-info/top_level.txt +1 -0
- awen_dlmax-0.1.0/tests/test_add_series_append.py +159 -0
- awen_dlmax-0.1.0/tests/test_add_series_many.py +284 -0
- awen_dlmax-0.1.0/tests/test_ar_stationarity_forecast.py +129 -0
- awen_dlmax-0.1.0/tests/test_autoffs_forecast_face.py +183 -0
- awen_dlmax-0.1.0/tests/test_block.py +80 -0
- awen_dlmax-0.1.0/tests/test_block_builder.py +282 -0
- awen_dlmax-0.1.0/tests/test_block_discount.py +127 -0
- awen_dlmax-0.1.0/tests/test_blocks_api.py +70 -0
- awen_dlmax-0.1.0/tests/test_compile_universe.py +325 -0
- awen_dlmax-0.1.0/tests/test_component_block.py +64 -0
- awen_dlmax-0.1.0/tests/test_cv_fast_path.py +83 -0
- awen_dlmax-0.1.0/tests/test_cv_nested_forecast.py +138 -0
- awen_dlmax-0.1.0/tests/test_cv_tails.py +255 -0
- awen_dlmax-0.1.0/tests/test_cv_xarray_output.py +159 -0
- awen_dlmax-0.1.0/tests/test_defragment.py +128 -0
- awen_dlmax-0.1.0/tests/test_devices.py +86 -0
- awen_dlmax-0.1.0/tests/test_discount_grid.py +293 -0
- awen_dlmax-0.1.0/tests/test_dma.py +127 -0
- awen_dlmax-0.1.0/tests/test_exog_universe.py +211 -0
- awen_dlmax-0.1.0/tests/test_exog_universe_grid.py +231 -0
- awen_dlmax-0.1.0/tests/test_factories.py +140 -0
- awen_dlmax-0.1.0/tests/test_fixed_capacity_batches.py +96 -0
- awen_dlmax-0.1.0/tests/test_forecast.py +147 -0
- awen_dlmax-0.1.0/tests/test_grid_ar_forecast.py +132 -0
- awen_dlmax-0.1.0/tests/test_grid_block.py +110 -0
- awen_dlmax-0.1.0/tests/test_grid_regressors.py +157 -0
- awen_dlmax-0.1.0/tests/test_grid_rtrl_regressors.py +208 -0
- awen_dlmax-0.1.0/tests/test_grid_seed_lags.py +331 -0
- awen_dlmax-0.1.0/tests/test_grid_vs_legacy_regressors.py +247 -0
- awen_dlmax-0.1.0/tests/test_ignore_obs_prior.py +144 -0
- awen_dlmax-0.1.0/tests/test_integer_ds.py +207 -0
- awen_dlmax-0.1.0/tests/test_localtrend_perstate.py +60 -0
- awen_dlmax-0.1.0/tests/test_multi_regression.py +207 -0
- awen_dlmax-0.1.0/tests/test_multiblock_add_series_many.py +169 -0
- awen_dlmax-0.1.0/tests/test_nested_forecast_equiv.py +40 -0
- awen_dlmax-0.1.0/tests/test_orchestrator_names.py +38 -0
- awen_dlmax-0.1.0/tests/test_power_law_safe_divide.py +90 -0
- awen_dlmax-0.1.0/tests/test_predictive.py +124 -0
- awen_dlmax-0.1.0/tests/test_qr_kernel.py +253 -0
- awen_dlmax-0.1.0/tests/test_regressors.py +118 -0
- awen_dlmax-0.1.0/tests/test_short_series.py +74 -0
- awen_dlmax-0.1.0/tests/test_smoke.py +35 -0
- awen_dlmax-0.1.0/tests/test_smoother.py +333 -0
- awen_dlmax-0.1.0/tests/test_static_block.py +91 -0
- awen_dlmax-0.1.0/tests/test_sweep.py +89 -0
- awen_dlmax-0.1.0/tests/test_union_dma.py +112 -0
- awen_dlmax-0.1.0/tests/test_union_stream.py +167 -0
- awen_dlmax-0.1.0/tests/test_universe.py +56 -0
- awen_dlmax-0.1.0/tests/test_universe_distributed.py +125 -0
- awen_dlmax-0.1.0/tests/test_universe_grid.py +359 -0
- awen_dlmax-0.1.0/tests/test_universe_persist.py +174 -0
- awen_dlmax-0.1.0/tests/test_uv_vs_multi_forecast_W.py +52 -0
- awen_dlmax-0.1.0/tests/test_wide_input.py +110 -0
- awen_dlmax-0.1.0/tests/test_wing_default.py +171 -0
awen_dlmax-0.1.0/LICENSE
ADDED
|
@@ -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 2026 Ross Hollyman
|
|
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.
|
awen_dlmax-0.1.0/NOTICE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
DLMAX — Dynamic Linear Models in JAX
|
|
2
|
+
Copyright 2026 Ross Hollyman
|
|
3
|
+
|
|
4
|
+
This product includes software developed by Ross Hollyman.
|
|
5
|
+
|
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
you may not use this file except in compliance with the License.
|
|
8
|
+
You may obtain a copy of the License at
|
|
9
|
+
|
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
|
|
12
|
+
If you use DLMAX or its methods in academic work, please cite the
|
|
13
|
+
accompanying paper (see CITATION.cff).
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: awen-dlmax
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Dynamic Linear Models in JAX
|
|
5
|
+
Author-email: Ross Hollyman <hello@awenforecasting.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/ross-h1/DLMAX
|
|
8
|
+
Project-URL: Repository, https://github.com/ross-h1/DLMAX
|
|
9
|
+
Project-URL: Issues, https://github.com/ross-h1/DLMAX/issues
|
|
10
|
+
Keywords: dynamic linear models,state space models,bayesian forecasting,model averaging,time series,forecasting,jax,kalman filter
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
17
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE
|
|
21
|
+
License-File: NOTICE
|
|
22
|
+
Requires-Dist: jax>=0.4
|
|
23
|
+
Requires-Dist: numpyro>=0.15
|
|
24
|
+
Requires-Dist: numpy>=1.26
|
|
25
|
+
Requires-Dist: scipy>=1.11
|
|
26
|
+
Requires-Dist: pandas>=2.0
|
|
27
|
+
Requires-Dist: matplotlib>=3.8
|
|
28
|
+
Requires-Dist: h5py>=3.16.0
|
|
29
|
+
Provides-Extra: gpu
|
|
30
|
+
Requires-Dist: jax[cuda12]; sys_platform == "linux" and extra == "gpu"
|
|
31
|
+
Provides-Extra: xarray
|
|
32
|
+
Requires-Dist: xarray>=2023.1; extra == "xarray"
|
|
33
|
+
Requires-Dist: h5netcdf>=1.0; extra == "xarray"
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
36
|
+
Requires-Dist: xarray>=2023.1; extra == "dev"
|
|
37
|
+
Requires-Dist: ruff>=0.6; extra == "dev"
|
|
38
|
+
Requires-Dist: jupyter; extra == "dev"
|
|
39
|
+
Dynamic: license-file
|
|
40
|
+
|
|
41
|
+
# DLMAX — Dynamic Linear Models in JAX
|
|
42
|
+
|
|
43
|
+
DLMAX is a JAX-based framework for **Dynamic Linear Models (DLMs)** with
|
|
44
|
+
**Discount Model Averaging (DMA)**. It fits and forecasts large panels of time
|
|
45
|
+
series under a Bayesian state-space formulation, averaging over a universe of
|
|
46
|
+
candidate models whose discount factors control how quickly each adapts. The
|
|
47
|
+
whole forward filter is written in JAX, so it vectorises across series and runs
|
|
48
|
+
on CPU or GPU.
|
|
49
|
+
|
|
50
|
+
DLMAX is the engine behind the paper *Forecasting: Fast and Slow*. The name
|
|
51
|
+
nods to the idea that a panel is best served not by one model but by a
|
|
52
|
+
*universe* of fast- and slow-adapting models, combined online by their
|
|
53
|
+
realised predictive performance.
|
|
54
|
+
|
|
55
|
+
> **Status: alpha (v0.1.0).** The numerics are tested and stable — the
|
|
56
|
+
> forecasts here are the ones behind the paper — but this is a `0.x` release and
|
|
57
|
+
> the public API may change between minor versions, per
|
|
58
|
+
> [semantic versioning](https://semver.org/#spec-item-4). Pin an exact version
|
|
59
|
+
> if you depend on it: `pip install awen-dlmax==0.1.0`.
|
|
60
|
+
>
|
|
61
|
+
> Bug reports and questions are welcome via
|
|
62
|
+
> [GitHub Issues](https://github.com/ross-h1/DLMAX/issues). If you hit a
|
|
63
|
+
> numerical problem, the most useful report includes the model spec, the shape
|
|
64
|
+
> of the panel, and whether 64-bit floats were enabled.
|
|
65
|
+
|
|
66
|
+
## Features
|
|
67
|
+
|
|
68
|
+
- **Component-based model builder** — compose `LocalLevel`, `LocalTrend`,
|
|
69
|
+
`Fourier` (seasonal), and `Regressors` (exogenous) terms into a DLM.
|
|
70
|
+
- **Discount Model Averaging** — maintain a universe of models differing in
|
|
71
|
+
their discount factors and combine them by online predictive score.
|
|
72
|
+
- **Online-learned discounts** — the default "wing" grid does not fix the
|
|
73
|
+
discount factors at all: each family carries three wingmen and the centre is
|
|
74
|
+
moved by online gradient descent, so the adaptation rate is learned per
|
|
75
|
+
series rather than chosen. This is the method of *Forecasting: Fast and Slow*.
|
|
76
|
+
- **Panel-scale** — vectorised across series; length-grouped batching handles
|
|
77
|
+
unbalanced panels; optional Dask distribution across a cluster.
|
|
78
|
+
- **Streaming API** — `fit` once, then `update` incrementally as new
|
|
79
|
+
observations arrive, with HDF5 persistence of filter state.
|
|
80
|
+
- **Probabilistic forecasts** — Student-t predictive intervals at arbitrary
|
|
81
|
+
horizons and coverage levels.
|
|
82
|
+
- **DataFrame interface** — long or wide input, accepted interchangeably
|
|
83
|
+
(see [Input format](#input-format)).
|
|
84
|
+
|
|
85
|
+
## Installation
|
|
86
|
+
|
|
87
|
+
DLMAX requires Python ≥ 3.11. The distribution is published as
|
|
88
|
+
**`awen-dlmax`**; the import name is `DLMAX`.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pip install awen-dlmax
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
For a GPU build of JAX (Linux + CUDA 12):
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
pip install "awen-dlmax[gpu]"
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
To reproduce published results, pin the exact version they were produced under
|
|
101
|
+
— `pip install awen-dlmax==0.1.0`.
|
|
102
|
+
|
|
103
|
+
DLMAX runs in double precision; enable 64-bit JAX before importing anything
|
|
104
|
+
that builds a model:
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
import jax
|
|
108
|
+
jax.config.update("jax_enable_x64", True)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Input format
|
|
112
|
+
|
|
113
|
+
Series are supplied as a pandas DataFrame in either of two shapes, detected
|
|
114
|
+
automatically.
|
|
115
|
+
|
|
116
|
+
**Long** — one row per observation, three columns:
|
|
117
|
+
|
|
118
|
+
| unique_id | ds | y |
|
|
119
|
+
|---|---|---|
|
|
120
|
+
| series_a | 2015-01-01 | 10.4 |
|
|
121
|
+
| series_a | 2015-02-01 | 11.1 |
|
|
122
|
+
| series_b | 2015-01-01 | 27.3 |
|
|
123
|
+
|
|
124
|
+
`unique_id` names the series, `ds` is the timestamp (or an integer index), `y`
|
|
125
|
+
is the observation. Series may be of different lengths and need not share a
|
|
126
|
+
calendar.
|
|
127
|
+
|
|
128
|
+
**Wide** — one row per period, one column per series:
|
|
129
|
+
|
|
130
|
+
| | series_a | series_b |
|
|
131
|
+
|---|---|---|
|
|
132
|
+
| **2015-01-01** | 10.4 | 27.3 |
|
|
133
|
+
| **2015-02-01** | 11.1 | 28.0 |
|
|
134
|
+
|
|
135
|
+
The index is the timestamp and the column names are the series ids. A series
|
|
136
|
+
that starts late or ends early is simply `NaN` in those cells; missing values
|
|
137
|
+
are carried through the filter as missing rather than imputed.
|
|
138
|
+
|
|
139
|
+
Both give identical results — wide input is converted to long internally, and
|
|
140
|
+
forecasts are returned keyed the way the input was.
|
|
141
|
+
|
|
142
|
+
## Quick start
|
|
143
|
+
|
|
144
|
+
```python
|
|
145
|
+
import jax
|
|
146
|
+
jax.config.update("jax_enable_x64", True)
|
|
147
|
+
|
|
148
|
+
import numpy as np
|
|
149
|
+
import pandas as pd
|
|
150
|
+
from DLMAX import AutoFFS
|
|
151
|
+
|
|
152
|
+
# A small monthly panel in long format: columns (unique_id, ds, y).
|
|
153
|
+
rng = np.random.default_rng(0)
|
|
154
|
+
dates = pd.date_range("2015-01-01", periods=72, freq="MS")
|
|
155
|
+
frames = []
|
|
156
|
+
for sid in ["series_a", "series_b", "series_c"]:
|
|
157
|
+
trend = np.linspace(0, 5, len(dates))
|
|
158
|
+
seasonal = 2.0 * np.sin(2 * np.pi * np.arange(len(dates)) / 12)
|
|
159
|
+
noise = rng.normal(0, 0.5, len(dates))
|
|
160
|
+
frames.append(pd.DataFrame({
|
|
161
|
+
"unique_id": sid,
|
|
162
|
+
"ds": dates,
|
|
163
|
+
"y": 10 + trend + seasonal + noise,
|
|
164
|
+
}))
|
|
165
|
+
df = pd.concat(frames, ignore_index=True)
|
|
166
|
+
|
|
167
|
+
# Fit a model universe (monthly seasonality) and forecast 12 steps ahead
|
|
168
|
+
# with 80% and 95% predictive intervals.
|
|
169
|
+
model = AutoFFS(season_length=12)
|
|
170
|
+
model.fit(df, freq="MS")
|
|
171
|
+
forecast = model.predict(h=12, level=[80, 95])
|
|
172
|
+
|
|
173
|
+
print(forecast.head())
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
`predict` returns a long-format DataFrame with the point forecast and the
|
|
177
|
+
requested interval bounds per `(unique_id, ds)`.
|
|
178
|
+
|
|
179
|
+
### Streaming updates
|
|
180
|
+
|
|
181
|
+
When the next period's observations arrive, `update` advances the filter over
|
|
182
|
+
the new rows only — no refit. Every fitted series must appear, and the panel
|
|
183
|
+
advances together.
|
|
184
|
+
|
|
185
|
+
```python
|
|
186
|
+
# next month's observation for each series
|
|
187
|
+
next_ds = dates[-1] + pd.offsets.MonthBegin(1)
|
|
188
|
+
df_new = pd.DataFrame({
|
|
189
|
+
"unique_id": ["series_a", "series_b", "series_c"],
|
|
190
|
+
"ds": [next_ds] * 3,
|
|
191
|
+
"y": [16.1, 15.4, 15.9],
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
model.update(df_new) # one filter pass over the new rows only
|
|
195
|
+
forecast = model.predict(h=12) # forecast from the advanced state
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
`fit(history)` then `update(new)` gives the same answer as `fit(history + new)`
|
|
199
|
+
— the filter is sequential, so how the data is fed in cannot change the result.
|
|
200
|
+
|
|
201
|
+
## Key concepts
|
|
202
|
+
|
|
203
|
+
- **`AutoFFS`** — the high-level estimator. Builds the model universe sized to
|
|
204
|
+
your data and exposes `fit` / `update` / `predict` for forecasting forward,
|
|
205
|
+
and `cross_validation` for rolling-origin backtests.
|
|
206
|
+
- **Model universe** — the set of candidate DLMs being averaged. The default is
|
|
207
|
+
the **wing grid** (below). Pass `blocks=[...]` for a different model set, or
|
|
208
|
+
`blocks=[StaticBlock(...)]` for a fixed-discount universe.
|
|
209
|
+
- **Discount factor** — governs how quickly a model forgets: 1 never forgets,
|
|
210
|
+
smaller adapts faster. The wing *learns* these. Separately, `dma_pdr` /
|
|
211
|
+
`dma_mdr` govern how fast the *averaging* re-weights toward
|
|
212
|
+
better-performing models.
|
|
213
|
+
- **`AutoFFSUniverse`** — the same model with state persisted to disk. Use it
|
|
214
|
+
when state must outlive the process, the panel does not fit in memory, or
|
|
215
|
+
series arrive over time (`add_series`). It agrees with `AutoFFS` bitwise.
|
|
216
|
+
|
|
217
|
+
### The wing grid, in six words
|
|
218
|
+
|
|
219
|
+
These terms recur throughout the API and the source:
|
|
220
|
+
|
|
221
|
+
| term | meaning |
|
|
222
|
+
|---|---|
|
|
223
|
+
| **grid** | the whole candidate model set for a series |
|
|
224
|
+
| **family** | one structure in that set — a choice of trend damping, seasonality on/off, and error law (additive or multiplicative) |
|
|
225
|
+
| **wing** | the mechanism that learns a discount rather than fixing it: a family carries trial discounts either side of a centre, and the centre moves toward whichever is scoring better |
|
|
226
|
+
| **wingman** | one of those trials. Three per family: one at the centre, one either side |
|
|
227
|
+
| **worker** | a single model — one family at one wingman offset. A 16-family grid has 48 workers |
|
|
228
|
+
| **union DMA** | the top-level averaging, run over *every* worker of *every* block at once, rather than combining each block separately and then combining the combinations |
|
|
229
|
+
|
|
230
|
+
So a forecast is: each worker filters the series, the wing moves each family's
|
|
231
|
+
discount centre using how its own wingmen scored, and the union DMA weights all
|
|
232
|
+
workers by recent predictive performance to produce the reported forecast.
|
|
233
|
+
|
|
234
|
+
## Awkward data
|
|
235
|
+
|
|
236
|
+
Real panels have series that cross zero, stop and start, or sit flat through
|
|
237
|
+
their warmup window. [`docs/INVARIANTS.md`](docs/INVARIANTS.md) documents what
|
|
238
|
+
DLMAX does in each case and why — missing values are carried as *no
|
|
239
|
+
information* rather than imputed, the variance link is symmetric about zero,
|
|
240
|
+
and the diffuse prior survives a partly-missing warmup. Worth reading if your
|
|
241
|
+
panel has any of those, and before changing the core filter.
|
|
242
|
+
|
|
243
|
+
## Development
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
git clone https://github.com/ross-h1/DLMAX.git
|
|
247
|
+
cd DLMAX
|
|
248
|
+
uv sync --extra dev # or: pip install -e ".[dev]"
|
|
249
|
+
pytest # runs the fast suite
|
|
250
|
+
pytest -m slow # also runs the slower numerical tests
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
Some tests exercise a private M1-competition dataset and are skipped unless
|
|
254
|
+
`DLMAX_M1M_PATH` points at a local copy; the default suite needs no external
|
|
255
|
+
data.
|
|
256
|
+
|
|
257
|
+
## Citation
|
|
258
|
+
|
|
259
|
+
If you use DLMAX or its methods in academic work, please cite the accompanying
|
|
260
|
+
paper. See [`CITATION.cff`](CITATION.cff), or use GitHub's *Cite this
|
|
261
|
+
repository* button.
|
|
262
|
+
|
|
263
|
+
## License
|
|
264
|
+
|
|
265
|
+
Apache License 2.0 — see [`LICENSE`](LICENSE) and [`NOTICE`](NOTICE).
|