lebre 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.
lebre-0.1.0/.gitignore ADDED
@@ -0,0 +1,7 @@
1
+ __pycache__/
2
+ *.pyc
3
+ .pytest_cache/
4
+ build/
5
+ dist/
6
+ *.egg-info/
7
+ .venv/
@@ -0,0 +1,23 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 — 2026-10-01
4
+
5
+ First release. Implements **LEBRE v0.52-r1** (canonical configuration) as frozen in the research record (https://doi.org/10.5281/zenodo.23049103).
6
+
7
+ **Fidelity.** In the reference environment (Windows, CPython 3.11, NumPy 2.2.5), forecasts, interval, events and cost accounting are bit-for-bit identical to the frozen research code. On other platforms and NumPy versions, rounding differs in the last bits; the tests then require identical structural decisions and forecasts within 1e-9 of their scale. This is checked on:
8
+ - seven synthetic scenarios (`tests/test_regression.py`);
9
+ - four real reserve-3 series, in the research repository (`scripts/check_lebre_package.py`).
10
+
11
+ **API:**
12
+ - `Lebre(n_inputs, season, season2)`;
13
+ - `predict` / `observe` / `step`;
14
+ - adaptive 90% interval;
15
+ - audit `events`, `structure`, `response`, `equivalent_inputs`;
16
+ - `coverage`, `cost_per_step`;
17
+ - `save` / `load`.
18
+
19
+ **Differences from the research code** (no effect on results):
20
+ - Branches used only by research ablations were removed.
21
+ - The single `step` was split into `predict` + `observe`.
22
+ - Interval hits are counted instead of stored.
23
+ - Missing input values (NaN) do not update the input standardiser; the research pipeline assumed complete inputs.
@@ -0,0 +1,17 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this software, please cite the LEBRE research record it implements."
3
+ type: software
4
+ title: "lebre: online forecasting with statistically tested structural changes"
5
+ version: "0.1.0"
6
+ authors:
7
+ - family-names: "Lima"
8
+ given-names: "Silvano"
9
+ orcid: "https://orcid.org/0009-0000-3868-6747"
10
+ license: Apache-2.0
11
+ references:
12
+ - type: software
13
+ title: "LEBRE research record — v0.52-r1"
14
+ authors:
15
+ - family-names: "Lima"
16
+ given-names: "Silvano"
17
+ doi: "10.5281/zenodo.23049103"
lebre-0.1.0/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
lebre-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,85 @@
1
+ Metadata-Version: 2.5
2
+ Name: lebre
3
+ Version: 0.1.0
4
+ Summary: Online one-step-ahead forecasting with statistically tested structural changes, at a cost of a few hundred operations per step (implements LEBRE v0.52-r1).
5
+ Project-URL: Source, https://github.com/Iquitim/lebre
6
+ Project-URL: Issues, https://github.com/Iquitim/lebre/issues
7
+ Project-URL: Research record, https://github.com/Iquitim/lebre-research
8
+ Project-URL: Research DOI, https://doi.org/10.5281/zenodo.23049103
9
+ Author: Silvano Lima
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: TinyML,anytime-valid inference,e-process,exogenous inputs,online forecasting,time series
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Topic :: Scientific/Engineering :: Information Analysis
18
+ Requires-Python: >=3.10
19
+ Requires-Dist: numpy>=1.24
20
+ Provides-Extra: test
21
+ Requires-Dist: pytest>=7; extra == 'test'
22
+ Description-Content-Type: text/markdown
23
+
24
+ # lebre
25
+
26
+ [![tests](https://github.com/Iquitim/lebre/actions/workflows/tests.yml/badge.svg)](https://github.com/Iquitim/lebre/actions/workflows/tests.yml)
27
+
28
+ Online one-step-ahead forecasting for a target driven by exogenous inputs, with **statistically tested structural changes**, at a cost of a few hundred floating-point operations per step.
29
+
30
+ `lebre 0.1.0` implements **LEBRE v0.52-r1**, the frozen research version documented and evaluated in the research record:
31
+ - repository: https://github.com/Iquitim/lebre-research
32
+ - DOI: [10.5281/zenodo.23049103](https://doi.org/10.5281/zenodo.23049103)
33
+
34
+ The package reproduces the research code **bit for bit in the reference environment** (Windows, CPython 3.11, NumPy 2.2.5), checked against references generated from the frozen code and on real evaluation series in the research repository. On other platforms and NumPy versions, floating-point rounding differs in the last bits (~1e-14): the regression tests then require identical structural decisions and forecasts equal within 1e-9 of their scale.
35
+
36
+ ```bash
37
+ pip install lebre
38
+ ```
39
+
40
+ ## Usage
41
+
42
+ ```python
43
+ from lebre import Lebre
44
+
45
+ model = Lebre(n_inputs=3, season=24) # season: declared cycle in steps (None if there is none)
46
+ for x_t, y_t in stream: # x_t: current inputs (length 3), y_t: target (None/NaN if missing)
47
+ f = model.predict(x_t) # Forecast(value, lower, upper, t), issued before y_t is known
48
+ model.observe(y_t)
49
+ # or: f = model.step(x_t, y_t)
50
+
51
+ model.structure # e.g. ['x0', 'own_past']
52
+ model.response("x0") # recovered lag response: [((lag_lo, lag_hi), weight per lag), ...]
53
+ model.events # audit log: Event(t, outcome, change, added, removed, log_evidence, samples)
54
+ model.equivalent_inputs("x0") # inputs indistinguishable from x0 (causal correlation >= 0.95)
55
+ model.coverage, model.cost_per_step # empirical 90%-interval coverage; analytic operations per step
56
+ model.save("state.pkl"); model = Lebre.load("state.pkl") # pickle: load only files you trust
57
+ ```
58
+
59
+ See `examples/quickstart.py`.
60
+
61
+ ## What it does
62
+
63
+ - **Live model:**
64
+ - a memory of the target's own past: level, declared cycle(s), per-phase profile;
65
+ - a linear regression on the current inputs;
66
+ - the two combined by dynamic model averaging.
67
+ - **Structural changes run in shadow as experiments:** adding, removing or swapping a whole input, or refining its lag response by hierarchical splits of octave bands.
68
+ - **Acceptance:** a change is accepted only when an anytime-valid e-process of predictive improvement crosses a level fixed by an online multiple-testing rule.
69
+ - **Output safeguards:** target gaps are held (never filled with the model's own forecasts), and forecasts stay within an envelope of the observed values.
70
+ - **Inputs:** they are standardised causally inside the model; set `standardize=False` only if you already do this with past-only statistics.
71
+
72
+ ## Scope and limits
73
+
74
+ These are the limits of the evaluated version, stated honestly (details in the specification, §19):
75
+ - evaluated on hydrology and building-energy series with 1–5 inputs, one step ahead;
76
+ - it is **not** meant to be the most accurate forecaster: in the evaluations it tied a SARIMAX with inputs fitted per series and had ~25% higher error than Chronos-2 with covariates, at a tiny fraction of the cost;
77
+ - the testing mechanism does not improve accuracy over switching all inputs on; its role is an audited, evidence-backed structure;
78
+ - an accepted input means *it improved the forecast of the current model, with evidence*, not *it is the cause*: correlated substitutes can be accepted, and near-identical inputs are indistinguishable;
79
+ - the e-values are valid under the stated assumptions; false-change control with the adaptive reference was verified empirically;
80
+ - delays of very smooth inputs are often not discovered (information limit), though forecasts remain good;
81
+ - the declared cost contract of the research version (mean ≤ 400, peak ≤ 1,000 operations per step) was narrowly not met.
82
+
83
+ ## Licence
84
+
85
+ Apache-2.0. If you use it, please cite the research record (`CITATION.cff`).
lebre-0.1.0/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # lebre
2
+
3
+ [![tests](https://github.com/Iquitim/lebre/actions/workflows/tests.yml/badge.svg)](https://github.com/Iquitim/lebre/actions/workflows/tests.yml)
4
+
5
+ Online one-step-ahead forecasting for a target driven by exogenous inputs, with **statistically tested structural changes**, at a cost of a few hundred floating-point operations per step.
6
+
7
+ `lebre 0.1.0` implements **LEBRE v0.52-r1**, the frozen research version documented and evaluated in the research record:
8
+ - repository: https://github.com/Iquitim/lebre-research
9
+ - DOI: [10.5281/zenodo.23049103](https://doi.org/10.5281/zenodo.23049103)
10
+
11
+ The package reproduces the research code **bit for bit in the reference environment** (Windows, CPython 3.11, NumPy 2.2.5), checked against references generated from the frozen code and on real evaluation series in the research repository. On other platforms and NumPy versions, floating-point rounding differs in the last bits (~1e-14): the regression tests then require identical structural decisions and forecasts equal within 1e-9 of their scale.
12
+
13
+ ```bash
14
+ pip install lebre
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```python
20
+ from lebre import Lebre
21
+
22
+ model = Lebre(n_inputs=3, season=24) # season: declared cycle in steps (None if there is none)
23
+ for x_t, y_t in stream: # x_t: current inputs (length 3), y_t: target (None/NaN if missing)
24
+ f = model.predict(x_t) # Forecast(value, lower, upper, t), issued before y_t is known
25
+ model.observe(y_t)
26
+ # or: f = model.step(x_t, y_t)
27
+
28
+ model.structure # e.g. ['x0', 'own_past']
29
+ model.response("x0") # recovered lag response: [((lag_lo, lag_hi), weight per lag), ...]
30
+ model.events # audit log: Event(t, outcome, change, added, removed, log_evidence, samples)
31
+ model.equivalent_inputs("x0") # inputs indistinguishable from x0 (causal correlation >= 0.95)
32
+ model.coverage, model.cost_per_step # empirical 90%-interval coverage; analytic operations per step
33
+ model.save("state.pkl"); model = Lebre.load("state.pkl") # pickle: load only files you trust
34
+ ```
35
+
36
+ See `examples/quickstart.py`.
37
+
38
+ ## What it does
39
+
40
+ - **Live model:**
41
+ - a memory of the target's own past: level, declared cycle(s), per-phase profile;
42
+ - a linear regression on the current inputs;
43
+ - the two combined by dynamic model averaging.
44
+ - **Structural changes run in shadow as experiments:** adding, removing or swapping a whole input, or refining its lag response by hierarchical splits of octave bands.
45
+ - **Acceptance:** a change is accepted only when an anytime-valid e-process of predictive improvement crosses a level fixed by an online multiple-testing rule.
46
+ - **Output safeguards:** target gaps are held (never filled with the model's own forecasts), and forecasts stay within an envelope of the observed values.
47
+ - **Inputs:** they are standardised causally inside the model; set `standardize=False` only if you already do this with past-only statistics.
48
+
49
+ ## Scope and limits
50
+
51
+ These are the limits of the evaluated version, stated honestly (details in the specification, §19):
52
+ - evaluated on hydrology and building-energy series with 1–5 inputs, one step ahead;
53
+ - it is **not** meant to be the most accurate forecaster: in the evaluations it tied a SARIMAX with inputs fitted per series and had ~25% higher error than Chronos-2 with covariates, at a tiny fraction of the cost;
54
+ - the testing mechanism does not improve accuracy over switching all inputs on; its role is an audited, evidence-backed structure;
55
+ - an accepted input means *it improved the forecast of the current model, with evidence*, not *it is the cause*: correlated substitutes can be accepted, and near-identical inputs are indistinguishable;
56
+ - the e-values are valid under the stated assumptions; false-change control with the adaptive reference was verified empirically;
57
+ - delays of very smooth inputs are often not discovered (information limit), though forecasts remain good;
58
+ - the declared cost contract of the research version (mean ≤ 400, peak ≤ 1,000 operations per step) was narrowly not met.
59
+
60
+ ## Licence
61
+
62
+ Apache-2.0. If you use it, please cite the research record (`CITATION.cff`).
@@ -0,0 +1,7 @@
1
+ # dev/
2
+
3
+ `make_fixtures.py` regenerates `tests/fixtures/` from the **frozen research implementation**. It needs a checkout of the research record (https://github.com/Iquitim/lebre-research) and is run from its root:
4
+
5
+ python packages/lebre/dev/make_fixtures.py
6
+
7
+ The fixtures are synthetic (seeds 5301–5307) and cover acceptance of inputs and of the residual state, hierarchical splits, swaps, removal tests, target gaps, out-of-contract inputs, quarantine, daily and weekly cycles, and a structureless target. An accepted removal and a "superseded" experiment do not occur in them. The removal code path is shared with the accepted swap.
@@ -0,0 +1,33 @@
1
+ """Quickstart: forecast a target driven by one delayed input, with a missing stretch of the target.
2
+
3
+ The target depends on input x0 with a delay of 12 steps; x1 is irrelevant. LEBRE learns online, forecasts one step
4
+ ahead and logs every structural change with its evidence.
5
+ """
6
+ import numpy as np
7
+
8
+ from lebre import Lebre
9
+
10
+ rng = np.random.default_rng(0)
11
+ T = 20000
12
+ X = np.zeros((T, 2))
13
+ for t in range(1, T):
14
+ X[t] = 0.5 * X[t - 1] + np.sqrt(0.75) * rng.standard_normal(2)
15
+ y = 0.8 * np.r_[np.zeros(12), X[:-12, 0]] + 0.5 * rng.standard_normal(T)
16
+ y[8000:8100] = np.nan # a gap in the target
17
+
18
+ model = Lebre(n_inputs=2)
19
+ err = []
20
+ for t in range(T):
21
+ f = model.predict(X[t]) # forecast before seeing y[t]
22
+ model.observe(None if np.isnan(y[t]) else y[t]) # then reveal y[t] (None = missing)
23
+ if t >= T // 2 and not np.isnan(y[t]):
24
+ err.append((y[t] - f.value) ** 2)
25
+
26
+ print(f"MSE on the second half: {np.mean(err):.3f} (noise variance 0.25)")
27
+ print(f"90% interval coverage: {model.coverage:.3f}")
28
+ print(f"active structure: {model.structure}")
29
+ print("recovered response of x0 (lags, weight per lag):", [(seg, round(w, 3)) for seg, w in model.response("x0")])
30
+ print(f"analytic cost: {model.cost_per_step:.0f} floating-point operations per step")
31
+ for e in model.events:
32
+ if e.outcome == "accepted":
33
+ print(f" t={e.t}: {e.change} {e.added} (log evidence {e.log_evidence}, {e.samples} samples)")
@@ -0,0 +1,40 @@
1
+ [build-system]
2
+ requires = ["hatchling>=1.21"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "lebre"
7
+ version = "0.1.0"
8
+ description = "Online one-step-ahead forecasting with statistically tested structural changes, at a cost of a few hundred operations per step (implements LEBRE v0.52-r1)."
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ license-files = ["LICENSE"]
12
+ requires-python = ">=3.10"
13
+ authors = [{ name = "Silvano Lima" }]
14
+ keywords = ["time series", "online forecasting", "anytime-valid inference", "e-process", "TinyML", "exogenous inputs"]
15
+ classifiers = [
16
+ "Development Status :: 3 - Alpha",
17
+ "Intended Audience :: Science/Research",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Scientific/Engineering :: Information Analysis",
20
+ "Operating System :: OS Independent",
21
+ ]
22
+ dependencies = ["numpy>=1.24"]
23
+
24
+ [project.optional-dependencies]
25
+ test = ["pytest>=7"]
26
+
27
+ [project.urls]
28
+ Source = "https://github.com/Iquitim/lebre"
29
+ Issues = "https://github.com/Iquitim/lebre/issues"
30
+ "Research record" = "https://github.com/Iquitim/lebre-research"
31
+ "Research DOI" = "https://doi.org/10.5281/zenodo.23049103"
32
+
33
+ [tool.hatch.build.targets.sdist]
34
+ include = ["src/lebre", "tests", "examples", "README.md", "LICENSE", "CHANGELOG.md", "CITATION.cff"]
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/lebre"]
38
+
39
+ [tool.pytest.ini_options]
40
+ testpaths = ["tests"]
@@ -0,0 +1,13 @@
1
+ """LEBRE — online one-step-ahead forecasting with statistically tested structural changes, at a cost of a few hundred
2
+ floating-point operations per step.
3
+
4
+ This package implements **LEBRE v0.52-r1** (canonical configuration) exactly as specified and evaluated in the research
5
+ record https://doi.org/10.5281/zenodo.23049103. In the reference environment (Windows, CPython 3.11, NumPy 2.2.5) the forecasts are bit-for-bit identical to the frozen
6
+ research code; elsewhere they agree up to floating-point rounding, with identical structural decisions in the tests.
7
+ """
8
+ from .model import Event, Forecast, Lebre
9
+
10
+ __version__ = "0.1.0"
11
+ ALGORITHM_VERSION = "LEBRE v0.52-r1"
12
+
13
+ __all__ = ["Lebre", "Forecast", "Event", "__version__", "ALGORITHM_VERSION"]