continuousintelligence 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.
- continuousintelligence-0.1.0/.python-version +1 -0
- continuousintelligence-0.1.0/LICENCE +95 -0
- continuousintelligence-0.1.0/MANIFEST.in +3 -0
- continuousintelligence-0.1.0/NOTICE +33 -0
- continuousintelligence-0.1.0/PKG-INFO +29 -0
- continuousintelligence-0.1.0/examples/forecast.py +119 -0
- continuousintelligence-0.1.0/pyproject.toml +63 -0
- continuousintelligence-0.1.0/setup.cfg +4 -0
- continuousintelligence-0.1.0/src/continuousintelligence/__init__.py +9 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_data/NOTICE +16 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_data/bike_sharing.csv +145 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_example.py +20 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_loader.py +140 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_plot.py +158 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/__init__.py +1 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/LICENSE +201 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/__init__.py +6 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/angle_dt.py +213 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/layernorm_gated.py +115 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/mamba3_mimo_fwd.py +483 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/mamba3_mimo_utils.py +112 -0
- continuousintelligence-0.1.0/src/continuousintelligence/_vendor/mamba3/utils.py +25 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/__init__.py +5 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_calendar.py +153 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_checkpoint.py +106 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_cuda.py +135 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_forecast.py +708 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_groups.py +198 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_mamba.py +190 -0
- continuousintelligence-0.1.0/src/continuousintelligence/ci_proto/_model.py +489 -0
- continuousintelligence-0.1.0/src/continuousintelligence.egg-info/PKG-INFO +29 -0
- continuousintelligence-0.1.0/src/continuousintelligence.egg-info/SOURCES.txt +47 -0
- continuousintelligence-0.1.0/src/continuousintelligence.egg-info/dependency_links.txt +1 -0
- continuousintelligence-0.1.0/src/continuousintelligence.egg-info/requires.txt +11 -0
- continuousintelligence-0.1.0/src/continuousintelligence.egg-info/top_level.txt +1 -0
- continuousintelligence-0.1.0/tests/conftest.py +77 -0
- continuousintelligence-0.1.0/tests/distribution.py +95 -0
- continuousintelligence-0.1.0/tests/test_calendar.py +82 -0
- continuousintelligence-0.1.0/tests/test_cuda.py +130 -0
- continuousintelligence-0.1.0/tests/test_example.py +34 -0
- continuousintelligence-0.1.0/tests/test_forecast.py +381 -0
- continuousintelligence-0.1.0/tests/test_groups.py +155 -0
- continuousintelligence-0.1.0/tests/test_hub.py +332 -0
- continuousintelligence-0.1.0/tests/test_inference_speedups.py +198 -0
- continuousintelligence-0.1.0/tests/test_loading.py +361 -0
- continuousintelligence-0.1.0/tests/test_metadata.py +233 -0
- continuousintelligence-0.1.0/tests/test_model.py +158 -0
- continuousintelligence-0.1.0/tests/test_plot.py +70 -0
- continuousintelligence-0.1.0/uv.lock +3457 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# ci-proto Code and Model Licence
|
|
2
|
+
|
|
3
|
+
Version 1.0, 10 November 2026
|
|
4
|
+
|
|
5
|
+
Licensor: Continuous Intelligence Limited
|
|
6
|
+
Release: ci-proto
|
|
7
|
+
Copyright 2026 Continuous Intelligence Limited
|
|
8
|
+
|
|
9
|
+
This licence is based on the Apache License, Version 2.0, with additional attribution and notification requirements in Section 10. It is designed to cover both software source code and AI model weights, with Section 10 also addressing the use of model outputs to develop other AI models.
|
|
10
|
+
|
|
11
|
+
**In brief:** Free for research and commercial use, subject to the attribution and notification requirements in Section 10. Redistribution and use in externally available products or services require public attribution and a one-time notification to Continuous Intelligence. Purely internal use is exempt from these additional requirements.
|
|
12
|
+
|
|
13
|
+
This summary is provided for convenience. The terms below govern use of the code and model.
|
|
14
|
+
|
|
15
|
+
## Terms and conditions for use, reproduction, and distribution
|
|
16
|
+
|
|
17
|
+
### 1. Definitions.
|
|
18
|
+
|
|
19
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 10 of this document.
|
|
20
|
+
|
|
21
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
22
|
+
|
|
23
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
24
|
+
|
|
25
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
28
|
+
|
|
29
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
30
|
+
|
|
31
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
|
32
|
+
|
|
33
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
34
|
+
|
|
35
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
36
|
+
|
|
37
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
38
|
+
|
|
39
|
+
### 2. Grant of Copyright License.
|
|
40
|
+
|
|
41
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
42
|
+
|
|
43
|
+
### 3. Grant of Patent License.
|
|
44
|
+
|
|
45
|
+
Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
46
|
+
|
|
47
|
+
### 4. Redistribution.
|
|
48
|
+
|
|
49
|
+
You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
50
|
+
|
|
51
|
+
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
52
|
+
|
|
53
|
+
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
54
|
+
|
|
55
|
+
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
56
|
+
|
|
57
|
+
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
|
|
58
|
+
|
|
59
|
+
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
60
|
+
|
|
61
|
+
### 5. Submission of Contributions.
|
|
62
|
+
|
|
63
|
+
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
64
|
+
|
|
65
|
+
### 6. Trademarks.
|
|
66
|
+
|
|
67
|
+
This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work, reproducing the content of the NOTICE file, and complying with Section 10.
|
|
68
|
+
|
|
69
|
+
### 7. Disclaimer of Warranty.
|
|
70
|
+
|
|
71
|
+
Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
72
|
+
|
|
73
|
+
### 8. Limitation of Liability.
|
|
74
|
+
|
|
75
|
+
In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
76
|
+
|
|
77
|
+
### 9. Accepting Warranty or Additional Liability.
|
|
78
|
+
|
|
79
|
+
While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
80
|
+
|
|
81
|
+
### 10. Additional attribution and notification.
|
|
82
|
+
|
|
83
|
+
For the purposes of this Section 10, "model weights" means the trained numerical parameters of the ci-proto model as released by the Licensor, which together determine the behaviour of the model.
|
|
84
|
+
|
|
85
|
+
If You distribute or make available the Work or any Derivative Work thereof relating to any part of the source or model weights, or a product or service (including another AI model) that contains or uses any of the Work's source code or model weights, You shall (A) provide a copy of this License with any such materials You distribute; and (B) prominently display "Uses ci-proto, released by Continuous Intelligence. Continuous Intelligence does not endorse or approve this product or service." on each related website, user interface, blogpost, about page, or product documentation. The attribution must be publicly accessible.
|
|
86
|
+
|
|
87
|
+
If You use the Work's source code, model weights or model outputs to create, train, fine tune, distil, or otherwise improve an AI model, which is distributed or made available, the attribution and notification requirements of this Section 10 shall also apply to that AI model and any externally available product or service that contains or uses it.
|
|
88
|
+
|
|
89
|
+
For each model released by Continuous Intelligence Limited whose source code, model weights or model outputs You use, You shall notify contact@continuousintelligence.co.uk once, on or before Your first distribution or making available under this Section 10, identifying You, the relevant model, a brief description of Your use or distribution, and the location of Your public attribution; this notification covers resulting models described above and does not require approval by the Licensor.
|
|
90
|
+
|
|
91
|
+
The Licensor may, by written notice, require You to remove the public-facing attribution required by this Section 10 from materials under Your control within 30 days of receiving that notice. The corresponding attribution requirement is waived for those materials. Required copyright and legal notices must remain. This does not affect Your other rights or obligations under this License.
|
|
92
|
+
|
|
93
|
+
The requirements of this Section 10 do not apply to purely internal use.
|
|
94
|
+
|
|
95
|
+
END OF TERMS AND CONDITIONS
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
Continuous Intelligence models — ci-proto
|
|
2
|
+
Copyright 2026 Continuous Intelligence Limited
|
|
3
|
+
|
|
4
|
+
Continuous Intelligence's contributions are covered by LICENCE. The upstream
|
|
5
|
+
components below retain their Apache License, Version 2.0 grants. The full
|
|
6
|
+
Apache licence text is included at:
|
|
7
|
+
|
|
8
|
+
src/continuousintelligence/_vendor/mamba3/LICENSE
|
|
9
|
+
|
|
10
|
+
TiRex-2
|
|
11
|
+
=======
|
|
12
|
+
Source: https://github.com/NX-AI/tirex-2
|
|
13
|
+
|
|
14
|
+
Copyright 2026 NXAI GmbH
|
|
15
|
+
|
|
16
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
17
|
+
you may not use this product except in compliance with the License.
|
|
18
|
+
You may obtain a copy of the License at
|
|
19
|
+
|
|
20
|
+
https://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
+
|
|
22
|
+
xLSTM
|
|
23
|
+
=====
|
|
24
|
+
Source: https://github.com/NX-AI/xlstm
|
|
25
|
+
Copyright 2024 NXAI GmbH and its affiliates 2024
|
|
26
|
+
|
|
27
|
+
Mamba
|
|
28
|
+
=====
|
|
29
|
+
Source: https://github.com/state-spaces/mamba
|
|
30
|
+
Copyright 2023 Tri Dao, Albert Gu
|
|
31
|
+
Copyright (c) 2024, Tri Dao.
|
|
32
|
+
Copyright (c) 2025, Dao AI Lab, Goombalab.
|
|
33
|
+
Copyright (c) 2026, Dao AI Lab, Goombalab.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: continuousintelligence
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Continuous Intelligence models
|
|
5
|
+
Author: Continuous Intelligence
|
|
6
|
+
License-Expression: LicenseRef-ci-proto AND Apache-2.0 AND CC-BY-4.0
|
|
7
|
+
Project-URL: Repository, https://github.com/continuousintelligence/ci
|
|
8
|
+
Project-URL: Issues, https://github.com/continuousintelligence/ci/issues
|
|
9
|
+
Keywords: time-series,forecasting,pytorch
|
|
10
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
12
|
+
Requires-Python: <3.15,>=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENCE
|
|
15
|
+
License-File: NOTICE
|
|
16
|
+
License-File: src/continuousintelligence/_vendor/mamba3/LICENSE
|
|
17
|
+
License-File: src/continuousintelligence/_data/NOTICE
|
|
18
|
+
Requires-Dist: torch<3,>=2.7
|
|
19
|
+
Requires-Dist: einops<1,>=0.8
|
|
20
|
+
Requires-Dist: huggingface-hub<3,>=1
|
|
21
|
+
Requires-Dist: numpy<3,>=1.26
|
|
22
|
+
Requires-Dist: pandas<4,>=2.2
|
|
23
|
+
Requires-Dist: matplotlib<4,>=3.8
|
|
24
|
+
Requires-Dist: tilelang==0.1.8; sys_platform == "linux" and platform_machine == "x86_64"
|
|
25
|
+
Requires-Dist: apache-tvm-ffi==0.1.9; sys_platform == "linux" and platform_machine == "x86_64"
|
|
26
|
+
Requires-Dist: cuda-toolkit[cccl,nvcc]==13.0.3; sys_platform == "linux" and platform_machine == "x86_64"
|
|
27
|
+
Dynamic: license-file
|
|
28
|
+
|
|
29
|
+
Continuous Intelligence models.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
"""Forecast a time series from a CSV file and plot ci-proto's median and quantile bands.
|
|
2
|
+
|
|
3
|
+
The default CSV holds five days of hourly bicycle rentals in Washington, D.C. from
|
|
4
|
+
UCI's Bike Sharing dataset (CC BY 4.0), followed by the 24 hours to forecast.
|
|
5
|
+
Any CSV with a timestamp column and a value column works:
|
|
6
|
+
|
|
7
|
+
- With a ``split`` column, rows marked ``history`` are observed and the rows marked
|
|
8
|
+
``forecast`` that follow them set the horizon and its timestamps.
|
|
9
|
+
- Without one, every row is history. Pass ``--horizon``; future timestamps continue the
|
|
10
|
+
frequency inferred from the history.
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
import argparse
|
|
14
|
+
import os
|
|
15
|
+
from importlib.resources import files
|
|
16
|
+
from pathlib import Path
|
|
17
|
+
|
|
18
|
+
import matplotlib
|
|
19
|
+
|
|
20
|
+
matplotlib.use("Agg")
|
|
21
|
+
import pandas as pd
|
|
22
|
+
import torch
|
|
23
|
+
|
|
24
|
+
from continuousintelligence import load_model, plot_forecast
|
|
25
|
+
|
|
26
|
+
DATA_PATH = files("continuousintelligence").joinpath("_data/bike_sharing.csv")
|
|
27
|
+
LABELS = {"rentals": "Bike rentals per hour"}
|
|
28
|
+
LEVELS = torch.arange(1, 10, dtype=torch.float32) / 10
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def read_series(
|
|
32
|
+
path: Path, time_column: str, value_column: str, horizon: int | None
|
|
33
|
+
) -> tuple[pd.DatetimeIndex, torch.Tensor, pd.DatetimeIndex]:
|
|
34
|
+
"""Return history timestamps, history values ``[1, T]`` and forecast timestamps."""
|
|
35
|
+
data = pd.read_csv(path)
|
|
36
|
+
missing = {time_column, value_column} - set(data.columns)
|
|
37
|
+
if missing:
|
|
38
|
+
raise ValueError(f"{path} has no column(s) {sorted(missing)}")
|
|
39
|
+
times = pd.DatetimeIndex(pd.to_datetime(data[time_column]))
|
|
40
|
+
if "split" in data:
|
|
41
|
+
if horizon is not None:
|
|
42
|
+
raise ValueError("--horizon applies only to CSVs without a split column")
|
|
43
|
+
split = data["split"]
|
|
44
|
+
if not split.isin(["history", "forecast"]).all():
|
|
45
|
+
raise ValueError("split values must be 'history' or 'forecast'")
|
|
46
|
+
observed = split.eq("history").to_numpy()
|
|
47
|
+
count = int(observed.sum())
|
|
48
|
+
if not observed[:count].all():
|
|
49
|
+
raise ValueError("history rows must come before forecast rows")
|
|
50
|
+
history_times, future_times = times[:count], times[count:]
|
|
51
|
+
values = data[value_column].iloc[:count]
|
|
52
|
+
else:
|
|
53
|
+
if horizon is None:
|
|
54
|
+
raise ValueError("pass --horizon for a CSV without a split column")
|
|
55
|
+
freq = pd.infer_freq(times) if len(times) >= 3 else None
|
|
56
|
+
if freq is None:
|
|
57
|
+
raise ValueError("timestamps have no regular frequency; add a split column")
|
|
58
|
+
history_times = times
|
|
59
|
+
future_times = pd.date_range(times[-1], periods=horizon + 1, freq=freq)[1:]
|
|
60
|
+
values = data[value_column]
|
|
61
|
+
if history_times.empty or future_times.empty:
|
|
62
|
+
raise ValueError("the CSV needs at least one history row and one forecast step")
|
|
63
|
+
history = torch.tensor(values.to_numpy(dtype=float), dtype=torch.float32)[None]
|
|
64
|
+
return history_times, history, future_times
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
def main() -> None:
|
|
68
|
+
"""Read a CSV series, forecast it and save the plot."""
|
|
69
|
+
parser = argparse.ArgumentParser(
|
|
70
|
+
description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter
|
|
71
|
+
)
|
|
72
|
+
parser.add_argument(
|
|
73
|
+
"--model", required=True, help="local bundle directory or Hugging Face model ID"
|
|
74
|
+
)
|
|
75
|
+
parser.add_argument("--revision", help="Hub revision; a commit SHA pins the model")
|
|
76
|
+
parser.add_argument("--device", choices=("auto", "cpu", "cuda"), default="auto")
|
|
77
|
+
parser.add_argument("--data", type=Path, default=DATA_PATH, help="CSV file to forecast")
|
|
78
|
+
parser.add_argument("--time-column", default="timestamp", help="column of timestamps")
|
|
79
|
+
parser.add_argument("--value-column", default="rentals", help="column to forecast")
|
|
80
|
+
parser.add_argument("--horizon", type=int, help="steps to forecast without a split column")
|
|
81
|
+
parser.add_argument("--ylabel", help="y-axis label (default: the value column)")
|
|
82
|
+
parser.add_argument("--output", type=Path, default=Path("outputs/forecast.png"))
|
|
83
|
+
parser.add_argument("--threads", type=int, default=min(4, os.cpu_count() or 1))
|
|
84
|
+
args = parser.parse_args()
|
|
85
|
+
if args.threads < 1:
|
|
86
|
+
parser.error("--threads must be positive")
|
|
87
|
+
if args.horizon is not None and args.horizon < 1:
|
|
88
|
+
parser.error("--horizon must be positive")
|
|
89
|
+
try:
|
|
90
|
+
history_times, history, future_times = read_series(
|
|
91
|
+
args.data, args.time_column, args.value_column, args.horizon
|
|
92
|
+
)
|
|
93
|
+
except ValueError as error:
|
|
94
|
+
parser.error(str(error))
|
|
95
|
+
torch.set_num_threads(args.threads)
|
|
96
|
+
model = load_model(args.model, device=args.device, revision=args.revision)
|
|
97
|
+
horizon = len(future_times)
|
|
98
|
+
prediction = model.forecast(history, horizon=horizon)
|
|
99
|
+
columns = (model.quantiles[:, None] - LEVELS).abs().argmin(dim=0)
|
|
100
|
+
if not torch.allclose(model.quantiles[columns], LEVELS, atol=1e-6, rtol=0):
|
|
101
|
+
raise ValueError("the checkpoint must provide quantiles 0.1 to 0.9 in increments of 0.1")
|
|
102
|
+
prediction = prediction[:, columns]
|
|
103
|
+
if not torch.isfinite(prediction).all():
|
|
104
|
+
raise RuntimeError("the model returned nonfinite forecasts")
|
|
105
|
+
ylabel = args.ylabel or LABELS.get(args.value_column, args.value_column)
|
|
106
|
+
plot_forecast(
|
|
107
|
+
history,
|
|
108
|
+
prediction,
|
|
109
|
+
model.quantiles[columns],
|
|
110
|
+
timestamps=history_times.append(future_times),
|
|
111
|
+
ylabel=ylabel,
|
|
112
|
+
output=args.output,
|
|
113
|
+
)
|
|
114
|
+
print(f"Device: {model.device} | History: {history.shape[-1]} | Horizon: {horizon}")
|
|
115
|
+
print(f"Saved {args.output.resolve()}")
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
if __name__ == "__main__":
|
|
119
|
+
main()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "continuousintelligence"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Continuous Intelligence models"
|
|
9
|
+
readme = { text = "Continuous Intelligence models.", content-type = "text/markdown" }
|
|
10
|
+
license = "LicenseRef-ci-proto AND Apache-2.0 AND CC-BY-4.0"
|
|
11
|
+
license-files = [
|
|
12
|
+
"LICENCE",
|
|
13
|
+
"NOTICE",
|
|
14
|
+
"src/continuousintelligence/_vendor/mamba3/LICENSE",
|
|
15
|
+
"src/continuousintelligence/_data/NOTICE",
|
|
16
|
+
]
|
|
17
|
+
requires-python = ">=3.10,<3.15"
|
|
18
|
+
authors = [{ name = "Continuous Intelligence" }]
|
|
19
|
+
keywords = ["time-series", "forecasting", "pytorch"]
|
|
20
|
+
classifiers = [
|
|
21
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
22
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
23
|
+
]
|
|
24
|
+
dependencies = [
|
|
25
|
+
"torch>=2.7,<3",
|
|
26
|
+
"einops>=0.8,<1",
|
|
27
|
+
"huggingface-hub>=1,<3",
|
|
28
|
+
"numpy>=1.26,<3",
|
|
29
|
+
"pandas>=2.2,<4",
|
|
30
|
+
"matplotlib>=3.8,<4",
|
|
31
|
+
"tilelang==0.1.8; sys_platform == 'linux' and platform_machine == 'x86_64'",
|
|
32
|
+
"apache-tvm-ffi==0.1.9; sys_platform == 'linux' and platform_machine == 'x86_64'",
|
|
33
|
+
"cuda-toolkit[nvcc,cccl]==13.0.3; sys_platform == 'linux' and platform_machine == 'x86_64'",
|
|
34
|
+
]
|
|
35
|
+
|
|
36
|
+
[project.urls]
|
|
37
|
+
Repository = "https://github.com/continuousintelligence/ci"
|
|
38
|
+
Issues = "https://github.com/continuousintelligence/ci/issues"
|
|
39
|
+
|
|
40
|
+
[dependency-groups]
|
|
41
|
+
dev = ["pytest>=8,<10", "ruff>=0.16,<0.18", "twine>=6,<8"]
|
|
42
|
+
|
|
43
|
+
[tool.uv]
|
|
44
|
+
required-version = ">=0.11.30"
|
|
45
|
+
|
|
46
|
+
[tool.setuptools.packages.find]
|
|
47
|
+
where = ["src"]
|
|
48
|
+
|
|
49
|
+
[tool.setuptools.package-data]
|
|
50
|
+
"continuousintelligence" = ["_data/*.csv", "_data/NOTICE"]
|
|
51
|
+
"continuousintelligence._vendor.mamba3" = ["LICENSE"]
|
|
52
|
+
|
|
53
|
+
[tool.pytest.ini_options]
|
|
54
|
+
testpaths = ["tests"]
|
|
55
|
+
addopts = "-ra --strict-config --strict-markers"
|
|
56
|
+
|
|
57
|
+
[tool.ruff]
|
|
58
|
+
line-length = 100
|
|
59
|
+
target-version = "py310"
|
|
60
|
+
extend-exclude = ["src/continuousintelligence/_vendor"]
|
|
61
|
+
|
|
62
|
+
[tool.ruff.lint]
|
|
63
|
+
select = ["E4", "E7", "E9", "F", "I", "B", "UP"]
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"""Continuous Intelligence models."""
|
|
2
|
+
|
|
3
|
+
from . import ci_proto
|
|
4
|
+
from ._example import load_example
|
|
5
|
+
from ._loader import load_model
|
|
6
|
+
from ._plot import plot_forecast
|
|
7
|
+
from .ci_proto import Forecaster
|
|
8
|
+
|
|
9
|
+
__all__ = ["ci_proto", "Forecaster", "load_example", "load_model", "plot_forecast"]
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Bike Sharing dataset — hourly bicycle rentals in Washington, D.C.
|
|
2
|
+
|
|
3
|
+
Hadi Fanaee-T (2013). Bike Sharing [Dataset]. UCI Machine Learning Repository.
|
|
4
|
+
https://doi.org/10.24432/C5W894
|
|
5
|
+
Licensed under Creative Commons Attribution 4.0 International (CC BY 4.0):
|
|
6
|
+
https://creativecommons.org/licenses/by/4.0/
|
|
7
|
+
|
|
8
|
+
Source: https://archive.ics.uci.edu/static/public/275/bike+sharing+dataset.zip
|
|
9
|
+
Extract: hour.csv, total rentals (cnt), 9–13 June 2012 (120 hourly observations).
|
|
10
|
+
Changes: selected dates and columns, renamed cnt to rentals; no smoothing or imputation.
|
|
11
|
+
The following 24 rows contain forecast timestamps only; their values are empty.
|
|
12
|
+
|
|
13
|
+
Publication requested by the source dataset:
|
|
14
|
+
Fanaee-T, H. and Gama, J. (2013). Event labeling combining ensemble detectors and
|
|
15
|
+
background knowledge. Progress in Artificial Intelligence.
|
|
16
|
+
https://doi.org/10.1007/s13748-013-0040-3
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
timestamp,rentals,split
|
|
2
|
+
2012-06-09T00:00:00,206,history
|
|
3
|
+
2012-06-09T01:00:00,123,history
|
|
4
|
+
2012-06-09T02:00:00,89,history
|
|
5
|
+
2012-06-09T03:00:00,40,history
|
|
6
|
+
2012-06-09T04:00:00,8,history
|
|
7
|
+
2012-06-09T05:00:00,19,history
|
|
8
|
+
2012-06-09T06:00:00,80,history
|
|
9
|
+
2012-06-09T07:00:00,87,history
|
|
10
|
+
2012-06-09T08:00:00,244,history
|
|
11
|
+
2012-06-09T09:00:00,340,history
|
|
12
|
+
2012-06-09T10:00:00,466,history
|
|
13
|
+
2012-06-09T11:00:00,569,history
|
|
14
|
+
2012-06-09T12:00:00,531,history
|
|
15
|
+
2012-06-09T13:00:00,585,history
|
|
16
|
+
2012-06-09T14:00:00,593,history
|
|
17
|
+
2012-06-09T15:00:00,555,history
|
|
18
|
+
2012-06-09T16:00:00,534,history
|
|
19
|
+
2012-06-09T17:00:00,495,history
|
|
20
|
+
2012-06-09T18:00:00,451,history
|
|
21
|
+
2012-06-09T19:00:00,360,history
|
|
22
|
+
2012-06-09T20:00:00,363,history
|
|
23
|
+
2012-06-09T21:00:00,316,history
|
|
24
|
+
2012-06-09T22:00:00,214,history
|
|
25
|
+
2012-06-09T23:00:00,230,history
|
|
26
|
+
2012-06-10T00:00:00,158,history
|
|
27
|
+
2012-06-10T01:00:00,116,history
|
|
28
|
+
2012-06-10T02:00:00,73,history
|
|
29
|
+
2012-06-10T03:00:00,29,history
|
|
30
|
+
2012-06-10T04:00:00,10,history
|
|
31
|
+
2012-06-10T05:00:00,13,history
|
|
32
|
+
2012-06-10T06:00:00,30,history
|
|
33
|
+
2012-06-10T07:00:00,62,history
|
|
34
|
+
2012-06-10T08:00:00,181,history
|
|
35
|
+
2012-06-10T09:00:00,266,history
|
|
36
|
+
2012-06-10T10:00:00,413,history
|
|
37
|
+
2012-06-10T11:00:00,499,history
|
|
38
|
+
2012-06-10T12:00:00,502,history
|
|
39
|
+
2012-06-10T13:00:00,492,history
|
|
40
|
+
2012-06-10T14:00:00,500,history
|
|
41
|
+
2012-06-10T15:00:00,475,history
|
|
42
|
+
2012-06-10T16:00:00,508,history
|
|
43
|
+
2012-06-10T17:00:00,521,history
|
|
44
|
+
2012-06-10T18:00:00,490,history
|
|
45
|
+
2012-06-10T19:00:00,375,history
|
|
46
|
+
2012-06-10T20:00:00,363,history
|
|
47
|
+
2012-06-10T21:00:00,253,history
|
|
48
|
+
2012-06-10T22:00:00,159,history
|
|
49
|
+
2012-06-10T23:00:00,110,history
|
|
50
|
+
2012-06-11T00:00:00,41,history
|
|
51
|
+
2012-06-11T01:00:00,24,history
|
|
52
|
+
2012-06-11T02:00:00,17,history
|
|
53
|
+
2012-06-11T03:00:00,6,history
|
|
54
|
+
2012-06-11T04:00:00,7,history
|
|
55
|
+
2012-06-11T05:00:00,37,history
|
|
56
|
+
2012-06-11T06:00:00,144,history
|
|
57
|
+
2012-06-11T07:00:00,503,history
|
|
58
|
+
2012-06-11T08:00:00,651,history
|
|
59
|
+
2012-06-11T09:00:00,316,history
|
|
60
|
+
2012-06-11T10:00:00,147,history
|
|
61
|
+
2012-06-11T11:00:00,202,history
|
|
62
|
+
2012-06-11T12:00:00,261,history
|
|
63
|
+
2012-06-11T13:00:00,248,history
|
|
64
|
+
2012-06-11T14:00:00,259,history
|
|
65
|
+
2012-06-11T15:00:00,259,history
|
|
66
|
+
2012-06-11T16:00:00,427,history
|
|
67
|
+
2012-06-11T17:00:00,800,history
|
|
68
|
+
2012-06-11T18:00:00,831,history
|
|
69
|
+
2012-06-11T19:00:00,596,history
|
|
70
|
+
2012-06-11T20:00:00,394,history
|
|
71
|
+
2012-06-11T21:00:00,250,history
|
|
72
|
+
2012-06-11T22:00:00,164,history
|
|
73
|
+
2012-06-11T23:00:00,80,history
|
|
74
|
+
2012-06-12T00:00:00,28,history
|
|
75
|
+
2012-06-12T01:00:00,16,history
|
|
76
|
+
2012-06-12T02:00:00,6,history
|
|
77
|
+
2012-06-12T03:00:00,12,history
|
|
78
|
+
2012-06-12T04:00:00,4,history
|
|
79
|
+
2012-06-12T05:00:00,29,history
|
|
80
|
+
2012-06-12T06:00:00,136,history
|
|
81
|
+
2012-06-12T07:00:00,303,history
|
|
82
|
+
2012-06-12T08:00:00,613,history
|
|
83
|
+
2012-06-12T09:00:00,285,history
|
|
84
|
+
2012-06-12T10:00:00,125,history
|
|
85
|
+
2012-06-12T11:00:00,65,history
|
|
86
|
+
2012-06-12T12:00:00,95,history
|
|
87
|
+
2012-06-12T13:00:00,59,history
|
|
88
|
+
2012-06-12T14:00:00,60,history
|
|
89
|
+
2012-06-12T15:00:00,116,history
|
|
90
|
+
2012-06-12T16:00:00,239,history
|
|
91
|
+
2012-06-12T17:00:00,681,history
|
|
92
|
+
2012-06-12T18:00:00,653,history
|
|
93
|
+
2012-06-12T19:00:00,491,history
|
|
94
|
+
2012-06-12T20:00:00,386,history
|
|
95
|
+
2012-06-12T21:00:00,274,history
|
|
96
|
+
2012-06-12T22:00:00,207,history
|
|
97
|
+
2012-06-12T23:00:00,89,history
|
|
98
|
+
2012-06-13T00:00:00,34,history
|
|
99
|
+
2012-06-13T01:00:00,28,history
|
|
100
|
+
2012-06-13T02:00:00,4,history
|
|
101
|
+
2012-06-13T03:00:00,8,history
|
|
102
|
+
2012-06-13T04:00:00,10,history
|
|
103
|
+
2012-06-13T05:00:00,40,history
|
|
104
|
+
2012-06-13T06:00:00,194,history
|
|
105
|
+
2012-06-13T07:00:00,505,history
|
|
106
|
+
2012-06-13T08:00:00,713,history
|
|
107
|
+
2012-06-13T09:00:00,352,history
|
|
108
|
+
2012-06-13T10:00:00,198,history
|
|
109
|
+
2012-06-13T11:00:00,246,history
|
|
110
|
+
2012-06-13T12:00:00,334,history
|
|
111
|
+
2012-06-13T13:00:00,255,history
|
|
112
|
+
2012-06-13T14:00:00,320,history
|
|
113
|
+
2012-06-13T15:00:00,281,history
|
|
114
|
+
2012-06-13T16:00:00,392,history
|
|
115
|
+
2012-06-13T17:00:00,857,history
|
|
116
|
+
2012-06-13T18:00:00,744,history
|
|
117
|
+
2012-06-13T19:00:00,671,history
|
|
118
|
+
2012-06-13T20:00:00,448,history
|
|
119
|
+
2012-06-13T21:00:00,396,history
|
|
120
|
+
2012-06-13T22:00:00,238,history
|
|
121
|
+
2012-06-13T23:00:00,153,history
|
|
122
|
+
2012-06-14T00:00:00,,forecast
|
|
123
|
+
2012-06-14T01:00:00,,forecast
|
|
124
|
+
2012-06-14T02:00:00,,forecast
|
|
125
|
+
2012-06-14T03:00:00,,forecast
|
|
126
|
+
2012-06-14T04:00:00,,forecast
|
|
127
|
+
2012-06-14T05:00:00,,forecast
|
|
128
|
+
2012-06-14T06:00:00,,forecast
|
|
129
|
+
2012-06-14T07:00:00,,forecast
|
|
130
|
+
2012-06-14T08:00:00,,forecast
|
|
131
|
+
2012-06-14T09:00:00,,forecast
|
|
132
|
+
2012-06-14T10:00:00,,forecast
|
|
133
|
+
2012-06-14T11:00:00,,forecast
|
|
134
|
+
2012-06-14T12:00:00,,forecast
|
|
135
|
+
2012-06-14T13:00:00,,forecast
|
|
136
|
+
2012-06-14T14:00:00,,forecast
|
|
137
|
+
2012-06-14T15:00:00,,forecast
|
|
138
|
+
2012-06-14T16:00:00,,forecast
|
|
139
|
+
2012-06-14T17:00:00,,forecast
|
|
140
|
+
2012-06-14T18:00:00,,forecast
|
|
141
|
+
2012-06-14T19:00:00,,forecast
|
|
142
|
+
2012-06-14T20:00:00,,forecast
|
|
143
|
+
2012-06-14T21:00:00,,forecast
|
|
144
|
+
2012-06-14T22:00:00,,forecast
|
|
145
|
+
2012-06-14T23:00:00,,forecast
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""The bundled real-data forecasting example."""
|
|
2
|
+
|
|
3
|
+
import csv
|
|
4
|
+
from importlib.resources import files
|
|
5
|
+
|
|
6
|
+
import torch
|
|
7
|
+
from torch import Tensor
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def load_example() -> Tensor:
|
|
11
|
+
"""Return the example's observed history as a CPU float32 tensor ``[1, 120]``.
|
|
12
|
+
|
|
13
|
+
Forecast rows are excluded. Each call returns a new tensor. Data attribution
|
|
14
|
+
and source information accompany the CSV in ``_data/NOTICE``.
|
|
15
|
+
"""
|
|
16
|
+
with files("continuousintelligence").joinpath("_data/bike_sharing.csv").open() as stream:
|
|
17
|
+
values = [
|
|
18
|
+
float(row["rentals"]) for row in csv.DictReader(stream) if row["split"] == "history"
|
|
19
|
+
]
|
|
20
|
+
return torch.tensor([values], dtype=torch.float32)
|