h2ofm 0.42.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 (36) hide show
  1. h2ofm-0.42.0/LICENSE +175 -0
  2. h2ofm-0.42.0/MANIFEST.in +1 -0
  3. h2ofm-0.42.0/PKG-INFO +196 -0
  4. h2ofm-0.42.0/README.md +177 -0
  5. h2ofm-0.42.0/THIRD_PARTY.md +33 -0
  6. h2ofm-0.42.0/pyproject.toml +33 -0
  7. h2ofm-0.42.0/setup.cfg +4 -0
  8. h2ofm-0.42.0/src/h2ofm/__init__.py +10 -0
  9. h2ofm-0.42.0/src/h2ofm/py.typed +0 -0
  10. h2ofm-0.42.0/src/h2ofm/timeh2o/__init__.py +6 -0
  11. h2ofm-0.42.0/src/h2ofm/timeh2o/_api.py +630 -0
  12. h2ofm-0.42.0/src/h2ofm/timeh2o/_checkpoints.py +139 -0
  13. h2ofm-0.42.0/src/h2ofm/timeh2o/_data/__init__.py +2 -0
  14. h2ofm-0.42.0/src/h2ofm/timeh2o/_data/dataset.py +80 -0
  15. h2ofm-0.42.0/src/h2ofm/timeh2o/_data/encoding.py +108 -0
  16. h2ofm-0.42.0/src/h2ofm/timeh2o/_data/preprocess.py +179 -0
  17. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/__init__.py +2 -0
  18. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/_refinement.py +134 -0
  19. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/config.py +117 -0
  20. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/flipeq.py +98 -0
  21. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/layers.py +29 -0
  22. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/model.py +341 -0
  23. h2ofm-0.42.0/src/h2ofm/timeh2o/_model/scaler.py +201 -0
  24. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/__init__.py +2 -0
  25. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/decoding.py +160 -0
  26. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/df_utils.py +375 -0
  27. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/pipeline.py +232 -0
  28. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/postprocess.py +47 -0
  29. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/tta.py +160 -0
  30. h2ofm-0.42.0/src/h2ofm/timeh2o/_pipeline/utils.py +168 -0
  31. h2ofm-0.42.0/src/h2ofm/timeh2o/_warnings.py +17 -0
  32. h2ofm-0.42.0/src/h2ofm.egg-info/PKG-INFO +196 -0
  33. h2ofm-0.42.0/src/h2ofm.egg-info/SOURCES.txt +34 -0
  34. h2ofm-0.42.0/src/h2ofm.egg-info/dependency_links.txt +1 -0
  35. h2ofm-0.42.0/src/h2ofm.egg-info/requires.txt +5 -0
  36. h2ofm-0.42.0/src/h2ofm.egg-info/top_level.txt +1 -0
h2ofm-0.42.0/LICENSE ADDED
@@ -0,0 +1,175 @@
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.
@@ -0,0 +1 @@
1
+ exclude AGENTS.md
h2ofm-0.42.0/PKG-INFO ADDED
@@ -0,0 +1,196 @@
1
+ Metadata-Version: 2.4
2
+ Name: h2ofm
3
+ Version: 0.42.0
4
+ Summary: H2O.ai Foundation Models — standalone inference
5
+ Author: H2O.ai
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://h2oai.com/
8
+ Keywords: foundation models,time series,forecasting
9
+ Requires-Python: >=3.12
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ License-File: THIRD_PARTY.md
13
+ Requires-Dist: numpy>=1.26
14
+ Requires-Dist: pandas>=2.0
15
+ Requires-Dist: torch<3,>=2.10
16
+ Requires-Dist: safetensors>=0.6.2
17
+ Requires-Dist: huggingface-hub>=0.34
18
+ Dynamic: license-file
19
+
20
+ # h2ofm — H2O.ai Foundation Models
21
+
22
+ Standalone inference for TimeH2O time-series models. Python 3.12+; CPU
23
+ and CUDA.
24
+
25
+ ```bash
26
+ pip install h2ofm
27
+ ```
28
+
29
+ ## Quick Start
30
+
31
+ ```python
32
+ import numpy as np
33
+ from h2ofm import TimeH2O
34
+
35
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
36
+ forecast = model.forecast(np.sin(np.arange(200) / 10), horizon=24)
37
+
38
+ forecast.point # (24,), median forecast; also forecast.median
39
+ forecast.quantiles # (24, 9), default levels 0.1 through 0.9
40
+ forecast.quantile(0.9) # (24,)
41
+ ```
42
+
43
+ Loading defaults to `device="auto"` (CUDA if available, otherwise CPU).
44
+ Set `batch_size` at load time (default 256): it counts target and covariate
45
+ rows, not series. Checkpoints without cross-variate attention drop covariate
46
+ rows first, so there only targets count. Checkpoint settings are available
47
+ through `model.config`.
48
+
49
+ ## Array Forecasts
50
+
51
+ `forecast(context, horizon=...)` returns a `Forecast` with CPU NumPy arrays:
52
+
53
+ | Input shape | `point` shape | `quantiles` shape |
54
+ | ---------------------- | ---------------------- | ------------------------------ |
55
+ | `(history,)` | `(horizon,)` | `(horizon, levels)` |
56
+ | `(targets, history)` | `(targets, horizon)` | `(targets, horizon, levels)` |
57
+
58
+ `forecast_many(contexts, horizon=...)` forecasts several independent series
59
+ in one pass. It takes a list of series, with possibly different history
60
+ lengths, and returns one `Forecast` per series in input order:
61
+
62
+ ```python
63
+ import numpy as np
64
+ from h2ofm import TimeH2O
65
+
66
+ contexts = [np.sin(np.arange(n) / 10) for n in (200, 150, 300)]
67
+
68
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
69
+ forecasts = model.forecast_many(contexts, horizon=24)
70
+
71
+ len(forecasts) # 3
72
+ forecasts[0].point # (24,)
73
+ forecasts[0].quantiles # (24, 9)
74
+ ```
75
+
76
+ For array inputs, the first axis is the batch: a 2D array batches univariate
77
+ series; a 3D array batches multi-target series.
78
+
79
+ `quantile_levels` selects output levels (default 0.1 through 0.9) and their
80
+ order on the last axis. Point forecasts are always medians.
81
+ NaN marks missing observations; all-missing targets use a zero-valued cold start.
82
+
83
+ Covariate arguments:
84
+
85
+ - `past_covariates`: values observed over the **history** only, shaped
86
+ `(history,)` or `(covariates, history)`. Ignored by checkpoints without
87
+ past-covariate support.
88
+ - `future_covariates`: known values spanning **history + horizon**, shaped
89
+ `(history + horizon,)` or `(covariates, history + horizon)`.
90
+ - For `forecast_many`, pass one covariate entry per series, using `None`
91
+ where absent.
92
+ - A covariate row is numeric when its dtype is numeric and not boolean.
93
+ Rows of any other dtype (strings, objects, booleans, `pd.Categorical`) are
94
+ categorical and encoded exactly as the matching `forecast_df` column, with
95
+ `None`/NaN as a missing label. Pass mixed covariates as a list of rows, e.g.
96
+ `[prices, holiday_names]`.
97
+
98
+ Checkpoints without cross-variate attention ignore covariates with a warning.
99
+
100
+ ## Dataframe Forecasts
101
+
102
+ Generate 100 days of two series with different periods and forecast the
103
+ next 24 days:
104
+
105
+ ```python
106
+ import numpy as np
107
+ import pandas as pd
108
+
109
+ from h2ofm import TimeH2O
110
+
111
+ history, horizon = 100, 24
112
+ days = np.arange(history)
113
+ dates = pd.date_range("2026-01-01", periods=len(days), freq="D")
114
+
115
+ frames = []
116
+ for item, period in [("weekly", 7), ("monthly", 30)]:
117
+ value = np.sin(2 * np.pi * days / period)
118
+ frames.append(pd.DataFrame({"item": item, "date": dates, "value": value}))
119
+ context = pd.concat(frames, ignore_index=True)
120
+
121
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
122
+ predictions = model.forecast_df(
123
+ context,
124
+ horizon=horizon,
125
+ target="value",
126
+ id_column="item",
127
+ time_column="date",
128
+ )
129
+ print(predictions.head())
130
+ ```
131
+
132
+ `target` is one column name or a list of target column names
133
+ (default `"target"`). Without `id_column`, the frame is one series;
134
+ without `time_column`, rows stay in input order.
135
+ The time column may contain datetimes or integer values representing time
136
+ steps. Integer times are never converted to dates; forecast rows continue them
137
+ at the inferred step, or at an integer `freq`.
138
+
139
+ `context` contains only history, including trailing missing measurements or
140
+ all-missing series. An integer `horizon` generates that many future steps per
141
+ item, and every covariate is past-only.
142
+
143
+ To supply future covariates, pass a horizon frame as `horizon` instead. Target
144
+ columns in it must be absent or entirely missing. Every covariate column in the
145
+ horizon frame is future-known, even when all its horizon values are missing (a
146
+ missing categorical value is itself informative, e.g. "no holiday"); leave
147
+ past-only covariates out of it, and timeh2o-v1 ignores them. Partial
148
+ missingness is allowed, including items with no known values for a covariate.
149
+
150
+ For panels, both frames must contain the same IDs, and every item in the
151
+ horizon frame must have the same number of rows. That count sets the horizon.
152
+ Future timestamps must continue each history at its inferred frequency (or the
153
+ explicit `freq`), even without future covariates. Without time columns, rows
154
+ retain their per-item input order. Neither input frame is mutated.
155
+
156
+ Output columns: the supplied ID and time columns (or `step`, 1 to `horizon`,
157
+ when no time column is given), `target_name`, `predictions` (median), and
158
+ one column per quantile, e.g. `"0.1"`. `freq` overrides inferred frequency:
159
+ a pandas offset alias for datetimes, the integer step between time values for
160
+ an integer time column.
161
+
162
+ ## Forecast Options
163
+
164
+ All three forecast methods accept:
165
+
166
+ | Option | Behavior |
167
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
168
+ | `context_length` | Shorten the checkpoint's context window. |
169
+ | `autoregressive=None` | Use the checkpoint's default. `True` decodes beyond `max_horizon` in blocks; `False` uses one pass. |
170
+ | `quantile_levels` | Distinct levels between 0 and 1; levels outside the trained 0.1–0.9 grid use Gaussian-tail extrapolation. |
171
+ | `flip_equivariant=False` | Set to `True` to make a flipped history always produce a flipped forecast. No extra pass for natively equivariant checkpoints; otherwise roughly doubles inference time. |
172
+ | `clip_nonnegative=False` | Set to `True` to clamp forecasts at zero for targets with nonnegative histories. Applied last. |
173
+
174
+ ## Model Checkpoints
175
+
176
+ | Name | Parameters | Multi-target | Past covariates | Future covariates | Flip equivariant |
177
+ | --------------------------- | ---------- | ------------ | --------------- | ----------------- | ---------------- |
178
+ | `h2oai/timeh2o-v1-tiny` | 5.8M | independent | No | No | Yes |
179
+
180
+ Multi-target modes, both forecasting the targets of an item in parallel:
181
+
182
+ - **independent**: each target is forecast from its own history, as if the
183
+ targets were separate independent series.
184
+ - **multivariate**: the targets are forecast as one multivariate series.
185
+
186
+ Past and future covariates are always validated, but a checkpoint only
187
+ uses the kinds it supports. The others are ignored with a warning.
188
+
189
+ Flip-equivariant checkpoints honor `flip_equivariant=True` without an extra
190
+ forecast pass; see Forecast Options.
191
+
192
+ ## License
193
+
194
+ Apache-2.0; see the `LICENSE` file in the distribution. Upstream attribution:
195
+ `THIRD_PARTY.md`, shipped alongside it.
196
+ Model weights are downloaded and licensed separately.
h2ofm-0.42.0/README.md ADDED
@@ -0,0 +1,177 @@
1
+ # h2ofm — H2O.ai Foundation Models
2
+
3
+ Standalone inference for TimeH2O time-series models. Python 3.12+; CPU
4
+ and CUDA.
5
+
6
+ ```bash
7
+ pip install h2ofm
8
+ ```
9
+
10
+ ## Quick Start
11
+
12
+ ```python
13
+ import numpy as np
14
+ from h2ofm import TimeH2O
15
+
16
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
17
+ forecast = model.forecast(np.sin(np.arange(200) / 10), horizon=24)
18
+
19
+ forecast.point # (24,), median forecast; also forecast.median
20
+ forecast.quantiles # (24, 9), default levels 0.1 through 0.9
21
+ forecast.quantile(0.9) # (24,)
22
+ ```
23
+
24
+ Loading defaults to `device="auto"` (CUDA if available, otherwise CPU).
25
+ Set `batch_size` at load time (default 256): it counts target and covariate
26
+ rows, not series. Checkpoints without cross-variate attention drop covariate
27
+ rows first, so there only targets count. Checkpoint settings are available
28
+ through `model.config`.
29
+
30
+ ## Array Forecasts
31
+
32
+ `forecast(context, horizon=...)` returns a `Forecast` with CPU NumPy arrays:
33
+
34
+ | Input shape | `point` shape | `quantiles` shape |
35
+ | ---------------------- | ---------------------- | ------------------------------ |
36
+ | `(history,)` | `(horizon,)` | `(horizon, levels)` |
37
+ | `(targets, history)` | `(targets, horizon)` | `(targets, horizon, levels)` |
38
+
39
+ `forecast_many(contexts, horizon=...)` forecasts several independent series
40
+ in one pass. It takes a list of series, with possibly different history
41
+ lengths, and returns one `Forecast` per series in input order:
42
+
43
+ ```python
44
+ import numpy as np
45
+ from h2ofm import TimeH2O
46
+
47
+ contexts = [np.sin(np.arange(n) / 10) for n in (200, 150, 300)]
48
+
49
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
50
+ forecasts = model.forecast_many(contexts, horizon=24)
51
+
52
+ len(forecasts) # 3
53
+ forecasts[0].point # (24,)
54
+ forecasts[0].quantiles # (24, 9)
55
+ ```
56
+
57
+ For array inputs, the first axis is the batch: a 2D array batches univariate
58
+ series; a 3D array batches multi-target series.
59
+
60
+ `quantile_levels` selects output levels (default 0.1 through 0.9) and their
61
+ order on the last axis. Point forecasts are always medians.
62
+ NaN marks missing observations; all-missing targets use a zero-valued cold start.
63
+
64
+ Covariate arguments:
65
+
66
+ - `past_covariates`: values observed over the **history** only, shaped
67
+ `(history,)` or `(covariates, history)`. Ignored by checkpoints without
68
+ past-covariate support.
69
+ - `future_covariates`: known values spanning **history + horizon**, shaped
70
+ `(history + horizon,)` or `(covariates, history + horizon)`.
71
+ - For `forecast_many`, pass one covariate entry per series, using `None`
72
+ where absent.
73
+ - A covariate row is numeric when its dtype is numeric and not boolean.
74
+ Rows of any other dtype (strings, objects, booleans, `pd.Categorical`) are
75
+ categorical and encoded exactly as the matching `forecast_df` column, with
76
+ `None`/NaN as a missing label. Pass mixed covariates as a list of rows, e.g.
77
+ `[prices, holiday_names]`.
78
+
79
+ Checkpoints without cross-variate attention ignore covariates with a warning.
80
+
81
+ ## Dataframe Forecasts
82
+
83
+ Generate 100 days of two series with different periods and forecast the
84
+ next 24 days:
85
+
86
+ ```python
87
+ import numpy as np
88
+ import pandas as pd
89
+
90
+ from h2ofm import TimeH2O
91
+
92
+ history, horizon = 100, 24
93
+ days = np.arange(history)
94
+ dates = pd.date_range("2026-01-01", periods=len(days), freq="D")
95
+
96
+ frames = []
97
+ for item, period in [("weekly", 7), ("monthly", 30)]:
98
+ value = np.sin(2 * np.pi * days / period)
99
+ frames.append(pd.DataFrame({"item": item, "date": dates, "value": value}))
100
+ context = pd.concat(frames, ignore_index=True)
101
+
102
+ model = TimeH2O.from_pretrained("h2oai/timeh2o-v1-tiny")
103
+ predictions = model.forecast_df(
104
+ context,
105
+ horizon=horizon,
106
+ target="value",
107
+ id_column="item",
108
+ time_column="date",
109
+ )
110
+ print(predictions.head())
111
+ ```
112
+
113
+ `target` is one column name or a list of target column names
114
+ (default `"target"`). Without `id_column`, the frame is one series;
115
+ without `time_column`, rows stay in input order.
116
+ The time column may contain datetimes or integer values representing time
117
+ steps. Integer times are never converted to dates; forecast rows continue them
118
+ at the inferred step, or at an integer `freq`.
119
+
120
+ `context` contains only history, including trailing missing measurements or
121
+ all-missing series. An integer `horizon` generates that many future steps per
122
+ item, and every covariate is past-only.
123
+
124
+ To supply future covariates, pass a horizon frame as `horizon` instead. Target
125
+ columns in it must be absent or entirely missing. Every covariate column in the
126
+ horizon frame is future-known, even when all its horizon values are missing (a
127
+ missing categorical value is itself informative, e.g. "no holiday"); leave
128
+ past-only covariates out of it, and timeh2o-v1 ignores them. Partial
129
+ missingness is allowed, including items with no known values for a covariate.
130
+
131
+ For panels, both frames must contain the same IDs, and every item in the
132
+ horizon frame must have the same number of rows. That count sets the horizon.
133
+ Future timestamps must continue each history at its inferred frequency (or the
134
+ explicit `freq`), even without future covariates. Without time columns, rows
135
+ retain their per-item input order. Neither input frame is mutated.
136
+
137
+ Output columns: the supplied ID and time columns (or `step`, 1 to `horizon`,
138
+ when no time column is given), `target_name`, `predictions` (median), and
139
+ one column per quantile, e.g. `"0.1"`. `freq` overrides inferred frequency:
140
+ a pandas offset alias for datetimes, the integer step between time values for
141
+ an integer time column.
142
+
143
+ ## Forecast Options
144
+
145
+ All three forecast methods accept:
146
+
147
+ | Option | Behavior |
148
+ | -------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
149
+ | `context_length` | Shorten the checkpoint's context window. |
150
+ | `autoregressive=None` | Use the checkpoint's default. `True` decodes beyond `max_horizon` in blocks; `False` uses one pass. |
151
+ | `quantile_levels` | Distinct levels between 0 and 1; levels outside the trained 0.1–0.9 grid use Gaussian-tail extrapolation. |
152
+ | `flip_equivariant=False` | Set to `True` to make a flipped history always produce a flipped forecast. No extra pass for natively equivariant checkpoints; otherwise roughly doubles inference time. |
153
+ | `clip_nonnegative=False` | Set to `True` to clamp forecasts at zero for targets with nonnegative histories. Applied last. |
154
+
155
+ ## Model Checkpoints
156
+
157
+ | Name | Parameters | Multi-target | Past covariates | Future covariates | Flip equivariant |
158
+ | --------------------------- | ---------- | ------------ | --------------- | ----------------- | ---------------- |
159
+ | `h2oai/timeh2o-v1-tiny` | 5.8M | independent | No | No | Yes |
160
+
161
+ Multi-target modes, both forecasting the targets of an item in parallel:
162
+
163
+ - **independent**: each target is forecast from its own history, as if the
164
+ targets were separate independent series.
165
+ - **multivariate**: the targets are forecast as one multivariate series.
166
+
167
+ Past and future covariates are always validated, but a checkpoint only
168
+ uses the kinds it supports. The others are ignored with a warning.
169
+
170
+ Flip-equivariant checkpoints honor `flip_equivariant=True` without an extra
171
+ forecast pass; see Forecast Options.
172
+
173
+ ## License
174
+
175
+ Apache-2.0; see the `LICENSE` file in the distribution. Upstream attribution:
176
+ `THIRD_PARTY.md`, shipped alongside it.
177
+ Model weights are downloaded and licensed separately.
@@ -0,0 +1,33 @@
1
+ ## Third-party attribution — H2OFM
2
+
3
+ The following parts of this package are adapted from
4
+ [amazon-science/chronos-forecasting](https://github.com/amazon-science/chronos-forecasting) **v2.3.1** (`chronos-forecasting==2.3.1`),
5
+ licensed under **Apache-2.0**:
6
+
7
+ - `src/h2ofm/timeh2o/_pipeline/df_utils.py`: dataframe validation,
8
+ normalization, frequency inference and future-frame construction, adapted
9
+ from `chronos/df_utils.py`.
10
+ - `src/h2ofm/timeh2o/_pipeline/utils.py`: quantile interpolation and weighted
11
+ quantiles, adapted from `chronos/utils.py`.
12
+ - `TimeH2O.forecast_df`: the dataframe interface, modeled on the Chronos-2
13
+ pipeline's `predict_df`.
14
+
15
+ Both files are modified by H2O.ai and say so in their headers. The model
16
+ itself is an independent implementation; methods it builds on are credited
17
+ below. The license is in `LICENSE`. Upstream notice, reproduced as required by
18
+ section 4(d) of the license:
19
+
20
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
21
+
22
+ **Method references:**
23
+
24
+ | Method | Reference |
25
+ | ----------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
26
+ | Causal arcsinh scaling and residual patch projections | [Toto 2.0](https://arxiv.org/abs/2605.20119) |
27
+ | CPM and parallel forecasting | [TiRex](https://arxiv.org/abs/2505.23719), [Toto 2.0](https://arxiv.org/abs/2605.20119) |
28
+ | CPM iterative RevIN | Google Research's TimesFM 3.0 team, [iterative refinement](https://github.com/google-research/timesfm/blob/master/src/timesfm3/torch/cpm_revin_refine.py) (2026) |
29
+ | Cross-variate attention | [Chronos-2](https://arxiv.org/abs/2510.15821) |
30
+ | Future-covariate lookahead | [TimesFM 3.0](https://github.com/google-research/timesfm) |
31
+ | Layers and scaling | [RoPE](https://arxiv.org/abs/2104.09864), [RMSNorm](https://arxiv.org/abs/1910.07467), [SwiGLU](https://arxiv.org/abs/2002.05202), [µP](https://arxiv.org/abs/2203.03466) |
32
+ | RevIN | Taesung Kim et al., [RevIN](https://openreview.net/forum?id=cGDAkQo1C0p) (ICLR 2022) |
33
+ | Test-time quantile averaging | [Vincentization](https://doi.org/10.1287/mnsc.1120.1667) |
@@ -0,0 +1,33 @@
1
+ [project]
2
+ name = "h2ofm"
3
+ version = "0.42.0"
4
+ description = "H2O.ai Foundation Models — standalone inference"
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ license = "Apache-2.0"
8
+ license-files = ["LICENSE", "THIRD_PARTY.md"]
9
+ authors = [{name = "H2O.ai"}]
10
+ keywords = ["foundation models", "time series", "forecasting"]
11
+ dependencies = [
12
+ "numpy>=1.26",
13
+ "pandas>=2.0",
14
+ "torch>=2.10,<3",
15
+ "safetensors>=0.6.2",
16
+ "huggingface-hub>=0.34",
17
+ ]
18
+
19
+ [project.urls]
20
+ Homepage = "https://h2oai.com/"
21
+
22
+ [build-system]
23
+ requires = ["setuptools>=77"]
24
+ build-backend = "setuptools.build_meta"
25
+
26
+ [tool.uv]
27
+ cache-keys = [{ file = "pyproject.toml" }, { file = "src/**/*.py" }]
28
+
29
+ [tool.setuptools.packages.find]
30
+ where = ["src"]
31
+
32
+ [tool.setuptools.package-data]
33
+ h2ofm = ["py.typed"]
h2ofm-0.42.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,10 @@
1
+ # Copyright 2026 H2O.ai, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from importlib.metadata import version
5
+
6
+ from . import timeh2o
7
+ from .timeh2o import TimeH2O
8
+
9
+ __version__ = version("h2ofm")
10
+ __all__ = ["TimeH2O", "timeh2o", "__version__"]
File without changes
@@ -0,0 +1,6 @@
1
+ # Copyright 2026 H2O.ai, Inc.
2
+ # SPDX-License-Identifier: Apache-2.0
3
+
4
+ from ._api import Forecast, TimeH2O
5
+
6
+ __all__ = ["Forecast", "TimeH2O"]