futureish 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.
- futureish-0.1.0/PKG-INFO +225 -0
- futureish-0.1.0/README.md +206 -0
- futureish-0.1.0/pyproject.toml +59 -0
- futureish-0.1.0/pyproject.toml.orig +66 -0
- futureish-0.1.0/src/futureish/__init__.py +13 -0
- futureish-0.1.0/src/futureish/_internal/__init__.py +1 -0
- futureish-0.1.0/src/futureish/_internal/constants.py +7 -0
- futureish-0.1.0/src/futureish/_internal/dummy.py +30 -0
- futureish-0.1.0/src/futureish/_internal/repr.py +257 -0
- futureish-0.1.0/src/futureish/catboost/__init__.py +12 -0
- futureish-0.1.0/src/futureish/catboost/model.py +141 -0
- futureish-0.1.0/src/futureish/datapoints/__init__.py +5 -0
- futureish-0.1.0/src/futureish/datapoints/base.py +24 -0
- futureish-0.1.0/src/futureish/datapoints/recorded.py +23 -0
- futureish-0.1.0/src/futureish/datapoints/time.py +12 -0
- futureish-0.1.0/src/futureish/datasets/__init__.py +19 -0
- futureish-0.1.0/src/futureish/datasets/base.py +322 -0
- futureish-0.1.0/src/futureish/datasets/config.py +394 -0
- futureish-0.1.0/src/futureish/datasets/dataset.py +69 -0
- futureish-0.1.0/src/futureish/datasets/forecast.py +109 -0
- futureish-0.1.0/src/futureish/datasets/online.py +73 -0
- futureish-0.1.0/src/futureish/datasets/online_training.py +69 -0
- futureish-0.1.0/src/futureish/datasets/predict.py +118 -0
- futureish-0.1.0/src/futureish/datasets/test.py +21 -0
- futureish-0.1.0/src/futureish/datasets/train.py +32 -0
- futureish-0.1.0/src/futureish/features/__init__.py +19 -0
- futureish-0.1.0/src/futureish/features/base.py +95 -0
- futureish-0.1.0/src/futureish/features/bucket.py +154 -0
- futureish-0.1.0/src/futureish/features/businessday.py +56 -0
- futureish-0.1.0/src/futureish/features/input_base.py +130 -0
- futureish-0.1.0/src/futureish/features/modular.py +91 -0
- futureish-0.1.0/src/futureish/features/recorded.py +86 -0
- futureish-0.1.0/src/futureish/features/recorded_base.py +68 -0
- futureish-0.1.0/src/futureish/features/sincos_time.py +93 -0
- futureish-0.1.0/src/futureish/features/sparse.py +95 -0
- futureish-0.1.0/src/futureish/features/target.py +78 -0
- futureish-0.1.0/src/futureish/forecasting/__init__.py +6 -0
- futureish-0.1.0/src/futureish/forecasting/forecaster.py +126 -0
- futureish-0.1.0/src/futureish/forecasting/inference.py +389 -0
- futureish-0.1.0/src/futureish/gpr/__init__.py +22 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/__init__.py +15 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/__init__.py +4 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/gpytorch_model.py +136 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/gpytorch_sgp.py +52 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/gpytorch_vgp.py +46 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/online_pep/__init__.py +5 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/online_pep/gpytorch_online_pep.py +113 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/online_pep/osgpr_pep.py +276 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/online_pep/pep_compute_base.py +171 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/backends/online_pep/sgpr_pep.py +107 -0
- futureish-0.1.0/src/futureish/gpr/gpytorch/gpytorch_model_trainer.py +242 -0
- futureish-0.1.0/src/futureish/modeling/__init__.py +7 -0
- futureish-0.1.0/src/futureish/modeling/base.py +153 -0
- futureish-0.1.0/src/futureish/modeling/config.py +21 -0
- futureish-0.1.0/src/futureish/scaling/__init__.py +13 -0
- futureish-0.1.0/src/futureish/scaling/base.py +38 -0
- futureish-0.1.0/src/futureish/scaling/chained.py +142 -0
- futureish-0.1.0/src/futureish/scaling/data.py +54 -0
- futureish-0.1.0/src/futureish/scaling/difference.py +37 -0
- futureish-0.1.0/src/futureish/scaling/noop.py +35 -0
- futureish-0.1.0/src/futureish/scaling/z_score.py +35 -0
- futureish-0.1.0/src/futureish/utils/__init__.py +8 -0
- futureish-0.1.0/src/futureish/utils/polars.py +246 -0
- futureish-0.1.0/src/futureish/utils/timedelta.py +285 -0
futureish-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: futureish
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Uncertainty aware time series library with online update/training support.
|
|
5
|
+
Author: Jakob Schneider
|
|
6
|
+
Author-email: Jakob Schneider <git@jaschn.de>
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
Requires-Dist: catboost>=1.2.10
|
|
9
|
+
Requires-Dist: numpy>=2.4.6
|
|
10
|
+
Requires-Dist: polars>=2.1.0
|
|
11
|
+
Requires-Dist: tqdm>=4.70.1
|
|
12
|
+
Requires-Dist: gpytorch>=1.15.2
|
|
13
|
+
Requires-Dist: linear-operator
|
|
14
|
+
Requires-Dist: numpy>=2.0
|
|
15
|
+
Requires-Dist: tqdm>=4.68.3
|
|
16
|
+
Requires-Dist: torch>=2.14.1
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
|
|
20
|
+
# futureish
|
|
21
|
+
|
|
22
|
+
`futureish` is a Python time-series forecasting library built to create probabilistic time series models with online update of models.
|
|
23
|
+
Its main feature is a online gaussian process model, but also features a Catboost model and allows easy implementation of other black-box models.
|
|
24
|
+
It features a powerfull interface and functions for defining inputs, targets and datasets
|
|
25
|
+
|
|
26
|
+
- Recorded, sparse, modular, calendar, cyclical, and bucketed input features
|
|
27
|
+
- Target features and configurable data preparation
|
|
28
|
+
- Z-score, Difference, and chained scalers
|
|
29
|
+
- Online dataset workflows
|
|
30
|
+
- GPyTorch Gaussian-process backends, including sparse and online PEP models
|
|
31
|
+
- CatBoost backend
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install futureish
|
|
37
|
+
```
|
|
38
|
+
or
|
|
39
|
+
```bash
|
|
40
|
+
uv add futureish
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick start
|
|
44
|
+
|
|
45
|
+
The following example creates a one-minute dataset, derives a lagged input
|
|
46
|
+
feature, and prepares training data:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
from futureish.datapoints import RecordedDataPoint
|
|
50
|
+
from futureish.features import RecordedInputFeature, BusinessDayFeature, SinCosTimeFeature
|
|
51
|
+
from futureish.scaling import DiffScaler, ZScoreScaler, ChainedScaler
|
|
52
|
+
from futureish.features import TargetFeature
|
|
53
|
+
from futureish.datasets import Dataset
|
|
54
|
+
from futureish.gpr import GPyTorchOnlinePEP, GPyTorchFitConfig
|
|
55
|
+
from futureish.forecasting import Forecaster
|
|
56
|
+
import torch
|
|
57
|
+
|
|
58
|
+
pas_dp = RecordedDataPoint(name="pas", step_size="30m", known_future=False)
|
|
59
|
+
|
|
60
|
+
input_features = [
|
|
61
|
+
RecordedInputFeature(pas_dp, feature_name="pas_lags", input_length="2h", scaler_factory=ChainedScaler.from_scalers(DiffScaler, ZScoreScaler)),
|
|
62
|
+
]
|
|
63
|
+
target_features = [
|
|
64
|
+
TargetFeature(pas_dp, feature_name="pas_feature", scaler_factory=ChainedScaler.from_scalers(DiffScaler, ZScoreScaler))
|
|
65
|
+
]
|
|
66
|
+
|
|
67
|
+
dataset = Dataset(
|
|
68
|
+
raw_data=data,
|
|
69
|
+
input_features=input_features,
|
|
70
|
+
target_features=target_features,
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
train_dataset, test_dataset = dataset.split_training_and_test_data(0.8)
|
|
74
|
+
|
|
75
|
+
model = Forecaster(GPyTorchOnlinePEP.wrapped(100, use_cuda=torch.cuda.is_available()))
|
|
76
|
+
model.fit(train_dataset, config=GPyTorchFitConfig(time_limit=120)) # train for 120 seconds
|
|
77
|
+
traj_data, ground_truth = test_dataset.create_prediction_trajectory(t0_offset="6h", pred_len="2d")
|
|
78
|
+
traj = model.predict_autoregressive(traj_data)
|
|
79
|
+
traj_sampled = model.predict_autoregressive(traj_data, samples=100)
|
|
80
|
+
traj_quantiles = (
|
|
81
|
+
traj_sampled
|
|
82
|
+
.group_by("time")
|
|
83
|
+
.agg([
|
|
84
|
+
pl.col("pas").quantile(0.1).alias("pas_10th_percentile"),
|
|
85
|
+
pl.col("pas").quantile(0.5).alias("pas_median"),
|
|
86
|
+
pl.col("pas").quantile(0.9).alias("pas_90th_percentile")
|
|
87
|
+
])
|
|
88
|
+
)
|
|
89
|
+
```
|
|
90
|
+
For full example see: [Example](examples/example.ipynb)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
Raw data must contain a `time` column and the columns referenced by the
|
|
94
|
+
configured datapoints. Feature names must be unique, and target datapoints
|
|
95
|
+
define the forecasting step size.
|
|
96
|
+
|
|
97
|
+
## Components:
|
|
98
|
+
|
|
99
|
+
### Datapoints
|
|
100
|
+
|
|
101
|
+
`RecordedDataPoint` describes a value recorded in the raw data. It defines the
|
|
102
|
+
column name, recording step size, and whether future values are known. A
|
|
103
|
+
datapoint is the common source used by input and target features.
|
|
104
|
+
```python
|
|
105
|
+
from futureish.datapoints import RecordedDataPoint
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
### Input Features
|
|
109
|
+
```python
|
|
110
|
+
from futureish.features import *
|
|
111
|
+
```
|
|
112
|
+
#### RecordedInputFeature
|
|
113
|
+
A basic input feature that includes the current value of the datapoint and optionally lags as defined in `input_length` and $t_1$ if `uses_future_data=True`.
|
|
114
|
+
`input_lenght` defines the lags, `None` results in only $t_0$ and a value defines how much in the past is included.
|
|
115
|
+
|
|
116
|
+
#### SparseInputFeature
|
|
117
|
+
Some functionality, but only uses every nth lag as defined in reduction factor. For example `reduction_factor=2` uses lags $t_0, t_{-2}, ...$
|
|
118
|
+
|
|
119
|
+
#### ModularInputFeature
|
|
120
|
+
Allows to create a custom function for creating features. The function gets a `pl.DataFrame` or `pl.LazyFrame`, the column name for the time, the name for the feature and the groups (which include t0)
|
|
121
|
+
|
|
122
|
+
#### BucketInputFeature
|
|
123
|
+
Creates buckets for the lags, that each can be modified or aggregated by a custom function defining the `pl.Expr`
|
|
124
|
+
|
|
125
|
+
#### SinCosTimeFeature
|
|
126
|
+
Cyclic time features for different time variable encoded with sin and cos
|
|
127
|
+
|
|
128
|
+
#### BusinessDayFeature
|
|
129
|
+
Creates a indicator if the current day is a business day or not. Can also include indications for previos days according the `day_history`
|
|
130
|
+
|
|
131
|
+
#### InputFeatureBase
|
|
132
|
+
Base class to create custom features. At minimum a `_create_features` needs to be implemented. For more control `create_features` can be implemented.
|
|
133
|
+
|
|
134
|
+
### Target Features
|
|
135
|
+
|
|
136
|
+
`TargetFeature` converts a recorded datapoint into the values the model learns
|
|
137
|
+
to predict and maps it back to the raw data format. Target features define the forecast outputs, can apply scaling and
|
|
138
|
+
optional bounds, and determine the forecasting step size used by the dataset.
|
|
139
|
+
|
|
140
|
+
### Scalers
|
|
141
|
+
|
|
142
|
+
Scalers transform feature values before model fitting and invert predictions
|
|
143
|
+
back to the original scale. Built-in scalers include `ZScoreScaler`, `DiffScaler` and `ChainedScaler` composes multiple scalers
|
|
144
|
+
when several transformations are needed.
|
|
145
|
+
|
|
146
|
+
#### ZScoreScaler
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
(x - x.mean()) / x.std()
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### DiffScaler
|
|
153
|
+
|
|
154
|
+
$x = t_{-1} - t_0$
|
|
155
|
+
|
|
156
|
+
#### Custom Scalers
|
|
157
|
+
|
|
158
|
+
Custom scalers can be implemented as a subclass from `ScalerBase` (interface) or `DataScaler` (Simplified if the scaling can be implemented as a simple `pl.Expr`)
|
|
159
|
+
|
|
160
|
+
### Dataset
|
|
161
|
+
|
|
162
|
+
`Dataset` combines raw time-series data with input and target features. It
|
|
163
|
+
validates and prepares the feature columns, fits scaling configuration on
|
|
164
|
+
training data, and can produce `TrainDataset` and `TestDataset` instances.
|
|
165
|
+
Specialized online, prediction, and forecasting datasets support incremental
|
|
166
|
+
updates and autoregressive prediction workflows.
|
|
167
|
+
The datasets are split to ensure seperation between training, test and prediction data.
|
|
168
|
+
|
|
169
|
+
The basic dataset can be split into train and test datasets with `split_training_and_test_data` or converted entirely to a training dataset with `to_train_dataset`
|
|
170
|
+
Also has a `iter` and `random_subset` method.
|
|
171
|
+
|
|
172
|
+
#### TrainDataset
|
|
173
|
+
Can be passed on to the fit method to train the model.
|
|
174
|
+
|
|
175
|
+
##### OnlineDataset
|
|
176
|
+
The same as the basic dataset, but specifiying the size of the first training step, which limits the amount of data that is available for fitting the scalers.
|
|
177
|
+
|
|
178
|
+
#### OnlineTrainingDataset
|
|
179
|
+
The training dataset for the `OnlineDataset`
|
|
180
|
+
|
|
181
|
+
#### TestDataset
|
|
182
|
+
Used to test the model performance and make predictions.
|
|
183
|
+
- `create_prediction_trajectory` creates a single prediction trajectory
|
|
184
|
+
- `create_all_trajectories` create all possible trajectories based on the data
|
|
185
|
+
- `create_all_single_inputs` creates all inputs to predict $t_{+1}$
|
|
186
|
+
|
|
187
|
+
### Forecaster
|
|
188
|
+
|
|
189
|
+
`Forecaster` holds the model and the configuration for the dataset. It provides fitting,
|
|
190
|
+
incremental fitting, point or distributional predictions, autoregressive
|
|
191
|
+
multi-step forecasts, samples, and forecast error metrics.
|
|
192
|
+
|
|
193
|
+
### Models
|
|
194
|
+
|
|
195
|
+
Models implement the common model interface used by `Forecaster`, allowing
|
|
196
|
+
different backends to be exchanged without changing the data pipeline. The
|
|
197
|
+
project currently provides GPyTorch Gaussian-process models, including sparse
|
|
198
|
+
and online PEP variants, and a CatBoost time-series model.
|
|
199
|
+
|
|
200
|
+
#### GPR Models
|
|
201
|
+
All models are implemented in Gpytorch and provide native uncertainty estimation
|
|
202
|
+
- `GPyTorchOnlinePEP` Online Trainable GPR model
|
|
203
|
+
- `GPyTorchSGP` Comparison model
|
|
204
|
+
- `GPyTorchVGP` Comparison model
|
|
205
|
+
|
|
206
|
+
All three models need to be wrapped to be used with the `Forecaster` class.
|
|
207
|
+
```python
|
|
208
|
+
Forecaster(GPyTorchOnlinePEP.wrapped(...))
|
|
209
|
+
```
|
|
210
|
+
Each can be customized with the number of inducing points and a custom Kernel based on Gpytorch Kernels.
|
|
211
|
+
|
|
212
|
+
#### Catboost
|
|
213
|
+
A wrapper for catboost, that can also provide uncertainty estimation.
|
|
214
|
+
|
|
215
|
+
#### Custom models
|
|
216
|
+
Custom models can be created by subclassing `ABCModel` and implementing `_fit` and `_predict_mean` and optionally `_predict` and `_predict_sample`.
|
|
217
|
+
|
|
218
|
+
## Status
|
|
219
|
+
|
|
220
|
+
This project is under active development. Public APIs and model behavior may
|
|
221
|
+
change as the library evolves.
|
|
222
|
+
|
|
223
|
+
But feel free to open issues if you encounter them or have questions.
|
|
224
|
+
|
|
225
|
+
**Copyright © [2026] Technical University of Denmark**
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# futureish
|
|
2
|
+
|
|
3
|
+
`futureish` is a Python time-series forecasting library built to create probabilistic time series models with online update of models.
|
|
4
|
+
Its main feature is a online gaussian process model, but also features a Catboost model and allows easy implementation of other black-box models.
|
|
5
|
+
It features a powerfull interface and functions for defining inputs, targets and datasets
|
|
6
|
+
|
|
7
|
+
- Recorded, sparse, modular, calendar, cyclical, and bucketed input features
|
|
8
|
+
- Target features and configurable data preparation
|
|
9
|
+
- Z-score, Difference, and chained scalers
|
|
10
|
+
- Online dataset workflows
|
|
11
|
+
- GPyTorch Gaussian-process backends, including sparse and online PEP models
|
|
12
|
+
- CatBoost backend
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pip install futureish
|
|
18
|
+
```
|
|
19
|
+
or
|
|
20
|
+
```bash
|
|
21
|
+
uv add futureish
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Quick start
|
|
25
|
+
|
|
26
|
+
The following example creates a one-minute dataset, derives a lagged input
|
|
27
|
+
feature, and prepares training data:
|
|
28
|
+
|
|
29
|
+
```python
|
|
30
|
+
from futureish.datapoints import RecordedDataPoint
|
|
31
|
+
from futureish.features import RecordedInputFeature, BusinessDayFeature, SinCosTimeFeature
|
|
32
|
+
from futureish.scaling import DiffScaler, ZScoreScaler, ChainedScaler
|
|
33
|
+
from futureish.features import TargetFeature
|
|
34
|
+
from futureish.datasets import Dataset
|
|
35
|
+
from futureish.gpr import GPyTorchOnlinePEP, GPyTorchFitConfig
|
|
36
|
+
from futureish.forecasting import Forecaster
|
|
37
|
+
import torch
|
|
38
|
+
|
|
39
|
+
pas_dp = RecordedDataPoint(name="pas", step_size="30m", known_future=False)
|
|
40
|
+
|
|
41
|
+
input_features = [
|
|
42
|
+
RecordedInputFeature(pas_dp, feature_name="pas_lags", input_length="2h", scaler_factory=ChainedScaler.from_scalers(DiffScaler, ZScoreScaler)),
|
|
43
|
+
]
|
|
44
|
+
target_features = [
|
|
45
|
+
TargetFeature(pas_dp, feature_name="pas_feature", scaler_factory=ChainedScaler.from_scalers(DiffScaler, ZScoreScaler))
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
dataset = Dataset(
|
|
49
|
+
raw_data=data,
|
|
50
|
+
input_features=input_features,
|
|
51
|
+
target_features=target_features,
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
train_dataset, test_dataset = dataset.split_training_and_test_data(0.8)
|
|
55
|
+
|
|
56
|
+
model = Forecaster(GPyTorchOnlinePEP.wrapped(100, use_cuda=torch.cuda.is_available()))
|
|
57
|
+
model.fit(train_dataset, config=GPyTorchFitConfig(time_limit=120)) # train for 120 seconds
|
|
58
|
+
traj_data, ground_truth = test_dataset.create_prediction_trajectory(t0_offset="6h", pred_len="2d")
|
|
59
|
+
traj = model.predict_autoregressive(traj_data)
|
|
60
|
+
traj_sampled = model.predict_autoregressive(traj_data, samples=100)
|
|
61
|
+
traj_quantiles = (
|
|
62
|
+
traj_sampled
|
|
63
|
+
.group_by("time")
|
|
64
|
+
.agg([
|
|
65
|
+
pl.col("pas").quantile(0.1).alias("pas_10th_percentile"),
|
|
66
|
+
pl.col("pas").quantile(0.5).alias("pas_median"),
|
|
67
|
+
pl.col("pas").quantile(0.9).alias("pas_90th_percentile")
|
|
68
|
+
])
|
|
69
|
+
)
|
|
70
|
+
```
|
|
71
|
+
For full example see: [Example](examples/example.ipynb)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
Raw data must contain a `time` column and the columns referenced by the
|
|
75
|
+
configured datapoints. Feature names must be unique, and target datapoints
|
|
76
|
+
define the forecasting step size.
|
|
77
|
+
|
|
78
|
+
## Components:
|
|
79
|
+
|
|
80
|
+
### Datapoints
|
|
81
|
+
|
|
82
|
+
`RecordedDataPoint` describes a value recorded in the raw data. It defines the
|
|
83
|
+
column name, recording step size, and whether future values are known. A
|
|
84
|
+
datapoint is the common source used by input and target features.
|
|
85
|
+
```python
|
|
86
|
+
from futureish.datapoints import RecordedDataPoint
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Input Features
|
|
90
|
+
```python
|
|
91
|
+
from futureish.features import *
|
|
92
|
+
```
|
|
93
|
+
#### RecordedInputFeature
|
|
94
|
+
A basic input feature that includes the current value of the datapoint and optionally lags as defined in `input_length` and $t_1$ if `uses_future_data=True`.
|
|
95
|
+
`input_lenght` defines the lags, `None` results in only $t_0$ and a value defines how much in the past is included.
|
|
96
|
+
|
|
97
|
+
#### SparseInputFeature
|
|
98
|
+
Some functionality, but only uses every nth lag as defined in reduction factor. For example `reduction_factor=2` uses lags $t_0, t_{-2}, ...$
|
|
99
|
+
|
|
100
|
+
#### ModularInputFeature
|
|
101
|
+
Allows to create a custom function for creating features. The function gets a `pl.DataFrame` or `pl.LazyFrame`, the column name for the time, the name for the feature and the groups (which include t0)
|
|
102
|
+
|
|
103
|
+
#### BucketInputFeature
|
|
104
|
+
Creates buckets for the lags, that each can be modified or aggregated by a custom function defining the `pl.Expr`
|
|
105
|
+
|
|
106
|
+
#### SinCosTimeFeature
|
|
107
|
+
Cyclic time features for different time variable encoded with sin and cos
|
|
108
|
+
|
|
109
|
+
#### BusinessDayFeature
|
|
110
|
+
Creates a indicator if the current day is a business day or not. Can also include indications for previos days according the `day_history`
|
|
111
|
+
|
|
112
|
+
#### InputFeatureBase
|
|
113
|
+
Base class to create custom features. At minimum a `_create_features` needs to be implemented. For more control `create_features` can be implemented.
|
|
114
|
+
|
|
115
|
+
### Target Features
|
|
116
|
+
|
|
117
|
+
`TargetFeature` converts a recorded datapoint into the values the model learns
|
|
118
|
+
to predict and maps it back to the raw data format. Target features define the forecast outputs, can apply scaling and
|
|
119
|
+
optional bounds, and determine the forecasting step size used by the dataset.
|
|
120
|
+
|
|
121
|
+
### Scalers
|
|
122
|
+
|
|
123
|
+
Scalers transform feature values before model fitting and invert predictions
|
|
124
|
+
back to the original scale. Built-in scalers include `ZScoreScaler`, `DiffScaler` and `ChainedScaler` composes multiple scalers
|
|
125
|
+
when several transformations are needed.
|
|
126
|
+
|
|
127
|
+
#### ZScoreScaler
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
(x - x.mean()) / x.std()
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### DiffScaler
|
|
134
|
+
|
|
135
|
+
$x = t_{-1} - t_0$
|
|
136
|
+
|
|
137
|
+
#### Custom Scalers
|
|
138
|
+
|
|
139
|
+
Custom scalers can be implemented as a subclass from `ScalerBase` (interface) or `DataScaler` (Simplified if the scaling can be implemented as a simple `pl.Expr`)
|
|
140
|
+
|
|
141
|
+
### Dataset
|
|
142
|
+
|
|
143
|
+
`Dataset` combines raw time-series data with input and target features. It
|
|
144
|
+
validates and prepares the feature columns, fits scaling configuration on
|
|
145
|
+
training data, and can produce `TrainDataset` and `TestDataset` instances.
|
|
146
|
+
Specialized online, prediction, and forecasting datasets support incremental
|
|
147
|
+
updates and autoregressive prediction workflows.
|
|
148
|
+
The datasets are split to ensure seperation between training, test and prediction data.
|
|
149
|
+
|
|
150
|
+
The basic dataset can be split into train and test datasets with `split_training_and_test_data` or converted entirely to a training dataset with `to_train_dataset`
|
|
151
|
+
Also has a `iter` and `random_subset` method.
|
|
152
|
+
|
|
153
|
+
#### TrainDataset
|
|
154
|
+
Can be passed on to the fit method to train the model.
|
|
155
|
+
|
|
156
|
+
##### OnlineDataset
|
|
157
|
+
The same as the basic dataset, but specifiying the size of the first training step, which limits the amount of data that is available for fitting the scalers.
|
|
158
|
+
|
|
159
|
+
#### OnlineTrainingDataset
|
|
160
|
+
The training dataset for the `OnlineDataset`
|
|
161
|
+
|
|
162
|
+
#### TestDataset
|
|
163
|
+
Used to test the model performance and make predictions.
|
|
164
|
+
- `create_prediction_trajectory` creates a single prediction trajectory
|
|
165
|
+
- `create_all_trajectories` create all possible trajectories based on the data
|
|
166
|
+
- `create_all_single_inputs` creates all inputs to predict $t_{+1}$
|
|
167
|
+
|
|
168
|
+
### Forecaster
|
|
169
|
+
|
|
170
|
+
`Forecaster` holds the model and the configuration for the dataset. It provides fitting,
|
|
171
|
+
incremental fitting, point or distributional predictions, autoregressive
|
|
172
|
+
multi-step forecasts, samples, and forecast error metrics.
|
|
173
|
+
|
|
174
|
+
### Models
|
|
175
|
+
|
|
176
|
+
Models implement the common model interface used by `Forecaster`, allowing
|
|
177
|
+
different backends to be exchanged without changing the data pipeline. The
|
|
178
|
+
project currently provides GPyTorch Gaussian-process models, including sparse
|
|
179
|
+
and online PEP variants, and a CatBoost time-series model.
|
|
180
|
+
|
|
181
|
+
#### GPR Models
|
|
182
|
+
All models are implemented in Gpytorch and provide native uncertainty estimation
|
|
183
|
+
- `GPyTorchOnlinePEP` Online Trainable GPR model
|
|
184
|
+
- `GPyTorchSGP` Comparison model
|
|
185
|
+
- `GPyTorchVGP` Comparison model
|
|
186
|
+
|
|
187
|
+
All three models need to be wrapped to be used with the `Forecaster` class.
|
|
188
|
+
```python
|
|
189
|
+
Forecaster(GPyTorchOnlinePEP.wrapped(...))
|
|
190
|
+
```
|
|
191
|
+
Each can be customized with the number of inducing points and a custom Kernel based on Gpytorch Kernels.
|
|
192
|
+
|
|
193
|
+
#### Catboost
|
|
194
|
+
A wrapper for catboost, that can also provide uncertainty estimation.
|
|
195
|
+
|
|
196
|
+
#### Custom models
|
|
197
|
+
Custom models can be created by subclassing `ABCModel` and implementing `_fit` and `_predict_mean` and optionally `_predict` and `_predict_sample`.
|
|
198
|
+
|
|
199
|
+
## Status
|
|
200
|
+
|
|
201
|
+
This project is under active development. Public APIs and model behavior may
|
|
202
|
+
change as the library evolves.
|
|
203
|
+
|
|
204
|
+
But feel free to open issues if you encounter them or have questions.
|
|
205
|
+
|
|
206
|
+
**Copyright © [2026] Technical University of Denmark**
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "futureish"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Uncertainty aware time series library with online update/training support."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license-file = "LICENSE"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
requires-python = ">=3.11"
|
|
9
|
+
dependencies = [
|
|
10
|
+
"catboost>=1.2.10",
|
|
11
|
+
"numpy>=2.4.6",
|
|
12
|
+
"polars>=2.1.0",
|
|
13
|
+
"tqdm>=4.70.1",
|
|
14
|
+
"gpytorch>=1.15.2",
|
|
15
|
+
"linear-operator",
|
|
16
|
+
"numpy>=2.0",
|
|
17
|
+
"tqdm>=4.68.3",
|
|
18
|
+
"torch>=2.14.1",
|
|
19
|
+
]
|
|
20
|
+
environments = [
|
|
21
|
+
"sys_platform == 'linux'",
|
|
22
|
+
"sys_platform == 'darwin'",
|
|
23
|
+
"sys_platform == 'win32'",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[[project.authors]]
|
|
27
|
+
name = "Jakob Schneider"
|
|
28
|
+
email = "git@jaschn.de"
|
|
29
|
+
|
|
30
|
+
[build-system]
|
|
31
|
+
requires = ["uv_build>=0.11.21,<0.13.0"]
|
|
32
|
+
build-backend = "uv_build"
|
|
33
|
+
|
|
34
|
+
[tool.uv]
|
|
35
|
+
required-environments = [
|
|
36
|
+
"sys_platform == 'linux'",
|
|
37
|
+
"sys_platform == 'darwin'",
|
|
38
|
+
"sys_platform == 'win32'",
|
|
39
|
+
]
|
|
40
|
+
default-groups = []
|
|
41
|
+
|
|
42
|
+
[tool.pyright]
|
|
43
|
+
reportUnusedImport = false
|
|
44
|
+
|
|
45
|
+
[[tool.pyright.executionEnvironments]]
|
|
46
|
+
root = "."
|
|
47
|
+
extraPaths = ["src"]
|
|
48
|
+
|
|
49
|
+
[dependency-groups]
|
|
50
|
+
examples = [
|
|
51
|
+
"ipykernel>=7.3.0",
|
|
52
|
+
"pip>=26.1.2",
|
|
53
|
+
"matplotlib>=3.11.0",
|
|
54
|
+
]
|
|
55
|
+
test = [
|
|
56
|
+
"pytest>=9.1.1",
|
|
57
|
+
"pytest-cov>=7.1.0",
|
|
58
|
+
"pytest-xdist>=3.8.0",
|
|
59
|
+
]
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "futureish"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Uncertainty aware time series library with online update/training support."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "Jakob Schneider", email = "git@jaschn.de" }
|
|
8
|
+
]
|
|
9
|
+
license-file = "LICENSE"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
|
|
12
|
+
requires-python = ">=3.11"
|
|
13
|
+
dependencies = [
|
|
14
|
+
"catboost>=1.2.10",
|
|
15
|
+
"numpy>=2.4.6",
|
|
16
|
+
"polars>=2.1.0",
|
|
17
|
+
"tqdm>=4.70.1",
|
|
18
|
+
"gpytorch>=1.15.2",
|
|
19
|
+
"linear-operator",
|
|
20
|
+
"numpy>=2.0",
|
|
21
|
+
"tqdm>=4.68.3",
|
|
22
|
+
"torch>=2.14.1",
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
environments = [
|
|
26
|
+
"sys_platform == 'linux'",
|
|
27
|
+
"sys_platform == 'darwin'",
|
|
28
|
+
"sys_platform == 'win32'",
|
|
29
|
+
]
|
|
30
|
+
|
|
31
|
+
[build-system]
|
|
32
|
+
requires = ["uv_build>=0.11.21,<0.13.0"]
|
|
33
|
+
build-backend = "uv_build"
|
|
34
|
+
|
|
35
|
+
[tool.uv]
|
|
36
|
+
required-environments = [
|
|
37
|
+
"sys_platform == 'linux'",
|
|
38
|
+
"sys_platform == 'darwin'",
|
|
39
|
+
"sys_platform == 'win32'",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
default-groups = [
|
|
43
|
+
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
[dependency-groups]
|
|
47
|
+
examples = [
|
|
48
|
+
"ipykernel>=7.3.0",
|
|
49
|
+
"pip>=26.1.2",
|
|
50
|
+
"matplotlib>=3.11.0",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
test = [
|
|
54
|
+
"pytest>=9.1.1",
|
|
55
|
+
"pytest-cov>=7.1.0",
|
|
56
|
+
"pytest-xdist>=3.8.0",
|
|
57
|
+
]
|
|
58
|
+
|
|
59
|
+
[tool.pyright]
|
|
60
|
+
reportUnusedImport = false
|
|
61
|
+
|
|
62
|
+
[[tool.pyright.executionEnvironments]]
|
|
63
|
+
root = "."
|
|
64
|
+
extraPaths = [
|
|
65
|
+
"src",
|
|
66
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
from pkgutil import extend_path
|
|
3
|
+
|
|
4
|
+
__path__ = extend_path(__path__, __name__)
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
__version__ = version("futureish")
|
|
8
|
+
except PackageNotFoundError:
|
|
9
|
+
__version__ = "0.0.0+unknown"
|
|
10
|
+
|
|
11
|
+
import polars as pl
|
|
12
|
+
|
|
13
|
+
pl.Config.set_engine_affinity("streaming")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Private implementation details for the timeseries package."""
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
from ..modeling.base import ABCModel
|
|
2
|
+
from ..modeling.config import FitConfig
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
import numpy as np
|
|
6
|
+
from numpy.typing import NDArray
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
from typing import Any, Callable, Optional
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class DummyModel(ABCModel):
|
|
13
|
+
def __init__(self):
|
|
14
|
+
super().__init__()
|
|
15
|
+
|
|
16
|
+
@property
|
|
17
|
+
def _repr_fields(self) -> dict[str, Any]:
|
|
18
|
+
return super()._repr_fields
|
|
19
|
+
|
|
20
|
+
def _fit(self, X: NDArray[np.float64], features: dict[str, NDArray[np.float64]], config: Optional[FitConfig] = None) -> None:
|
|
21
|
+
pass
|
|
22
|
+
|
|
23
|
+
def _predict(self, X: NDArray[np.float64]) -> dict[str, tuple[NDArray[np.float64], NDArray[np.float64]]]:
|
|
24
|
+
return {name: (np.repeat(np.array([1.0]), X.shape[0]), np.repeat(np.array([0.0]), X.shape[0])) for name in self.feature_names}
|
|
25
|
+
|
|
26
|
+
def _predict_mean(self, X: NDArray[np.float64]) -> dict[str, NDArray[np.float64]]:
|
|
27
|
+
return {name: mean for name, (mean, _) in self._predict(X).items()}
|
|
28
|
+
|
|
29
|
+
def _predict_sample(self, X: NDArray[np.float64]) -> dict[str, NDArray[np.float64]]:
|
|
30
|
+
return {name: mean for name, (mean, _) in self._predict(X).items()}
|