TimesFM Forecasting

TimesFM Forecasting

Guides an AI agent through zero-shot time-series forecasting with Google's TimesFM: CSV preparation, quantile forecasts, covariates and held-out evaluation.

Skill files21 files

references/

scripts/

examples/anomaly-detection/

examples/covariates-forecasting/

examples/global-temperature/

SKILL.md172 lines
1
---
2
name: timesfm-forecasting
3
description: Performs zero-shot time-series forecasting with Google's TimesFM, including regular-grid CSV preparation, quantile forecasts, XReg covariates, and held-out evaluation. Uses the Apache-licensed TimesFM 2.5 checkpoint by default and documents the distinct TimesFM 3.0 multivariate API and weight-license requirements.
4
allowed-tools: Read Write Edit Bash
5
license: Apache-2.0 license
6
compatibility: Requires Python 3.10+ and timesfm 3.0.2 with PyTorch; CSV tooling also needs NumPy and pandas. Network access and cache space are needed for initial Hugging Face checkpoint download. Optional XReg needs JAX and scikit-learn; current JAX requires Python 3.12+.
7
metadata:
8
version: "3.0"
9
skill-author: Clayton Young / Superior Byte Works, LLC (@borealBytes)
10
last-reviewed: "2026-10-01"
11
tested-package: "timesfm 3.0.2"
12
---
13
14
# TimesFM Forecasting
15
16
## Choose the model/API first
17
18
The **Python package version is 3.0.2**; checkpoint versions are separate.
19
20
| Checkpoint | Interface | Quantile output | Usage terms |
21
| --- | --- | --- | --- |
22
| 2.5, 200M | `timesfm.TimesFM_2p5_200M_torch`, `compile`, `forecast` | mean + 9 deciles, median index 5 | Apache-2.0 weights; bundled CLI default |
23
| 3.0, about 330M | `timesfm3.TimesFM3Forecaster`, `predict` / `predict_batch` | 9 deciles, median index 4 | Downloaded weights restricted to non-commercial, non-production use |
24
25
Upstream identifies 3.0 as the latest model. This skill retains 2.5 as its default
26
local workflow because its Apache-licensed weights have different usage terms.
27
For 3.0 multivariate targets, past-only covariates or Apple MLX, read
28
[references/timesfm3.md](references/timesfm3.md) before adapting code. Authorized
29
Google Cloud services have separate terms; a Cloud entitlement does not change
30
the license of downloaded weights. See the [upstream license notice](https://github.com/google-research/timesfm#license-notice-for-pretrained-weights).
31
32
Use TimesFM for forecasting an ordered temporal target without task-specific
33
model training. It is not a causal effect estimator, clinical detector, or
34
physics-based climate model. Zero-shot describes fitting; it does not establish
35
absence of benchmark overlap in pretraining or good accuracy in a new domain.
36
37
## Workflow
38
39
1. Establish cadence, units, forecast origin, horizon, known-at-origin covariates,
40
evaluation cutoffs and a naive/seasonal-naive baseline.
41
2. Validate a sorted, unique, regular time grid. Do not `dropna()` internal gaps:
42
that changes temporal spacing. Reject nonfinite inputs, or explicitly impute
43
inside each training history. Never fill using held-out future targets.
44
3. Run `python scripts/check_system.py` before downloading/loading weights.
45
Its available-RAM and cache-volume thresholds are heuristics, not a guarantee
46
against OOM. Start with batch size 1; measure actual peak usage.
47
4. Load the chosen checkpoint with a recorded immutable revision. For 2.5,
48
compile explicit positive context/horizon settings; zero does **not** mean
49
“use the maximum.” Keep patch-rounded context + horizon <=16,384 and horizon
50
<=1,024 when using the continuous quantile head.
51
5. Forecast, validate shapes/finite values/quantile ordering and export the
52
forecast origin, frequency, configuration and checkpoint revision.
53
6. Evaluate across rolling origins with preprocessing fitted independently per
54
origin. Report accuracy, interval coverage and interval width by horizon;
55
label quantile intervals **nominal** until calibrated on relevant data.
56
57
## Installation
58
59
Run in a separate environment. The commands below target the reviewed release.
60
Shell extras and version constraints must be quoted, particularly in zsh.
61
62
```bash
63
uv venv .venv-timesfm
64
uv pip install --python .venv-timesfm/bin/python "timesfm[torch]==3.0.2" numpy pandas
65
.venv-timesfm/bin/python scripts/check_system.py
66
```
67
68
Use the current [PyTorch installation selector](https://pytorch.org/get-started/locally/)
69
for a CUDA wheel matching the host. The 2.5 loader in this release chooses
70
`cuda:0` if CUDA exists, otherwise CPU; detecting MPS does **not** enable MPS
71
inference. Do not use `model.to(...)` on the wrapper as if it were an `nn.Module`.
72
For CPU-only XReg, install `jax` and `scikit-learn` alongside the PyTorch profile;
73
the upstream `[xreg]` extra requests `jax[cuda]`, which is not appropriate for macOS.
74
Flax is a separate optional backend; it is not required by the bundled scripts.
75
76
```python
77
from importlib.metadata import version
78
import timesfm
79
print(version("timesfm")) # package has no guaranteed timesfm.__version__
80
assert hasattr(timesfm, "TimesFM_2p5_200M_torch")
81
```
82
83
## TimesFM 2.5 quick start
84
85
The checkpoint-load examples are illustrative: validation of this refresh used
86
native package code with tiny random models and controlled decode fixtures,
87
without downloading pretrained weights. That verifies mechanics, not accuracy.
88
89
```python
90
import numpy as np
91
import timesfm
92
93
model = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
94
"google/timesfm-2.5-200m-pytorch",
95
revision="1d952420fba87f3c6dee4f240de0f1a0fbc790e3",
96
torch_compile=False, # avoid compilation startup during an initial smoke run
97
)
98
model.compile(timesfm.ForecastConfig(
99
max_context=512, max_horizon=128, per_core_batch_size=1,
100
normalize_inputs=True, use_continuous_quantile_head=True,
101
force_flip_invariance=True, infer_is_positive=False,
102
fix_quantile_crossing=True,
103
))
104
histories = [np.sin(np.linspace(0, 20, 200)).astype(np.float32)]
105
# 2.5 may append dummy series to its input list during batching; pass a fresh list.
106
point, q = model.forecast(horizon=24, inputs=list(histories))
107
assert point.shape == (1, 24) and q.shape == (1, 24, 10)
108
assert np.isfinite(q).all() and np.all(np.diff(q[..., 1:], axis=-1) >= 0)
109
assert np.allclose(point, q[..., 5])
110
lower_80, upper_80 = q[..., 1], q[..., 9] # q10-q90: nominal 80% PI
111
lower_60, upper_60 = q[..., 2], q[..., 8] # q20-q80: nominal 60% PI
112
```
113
114
Set `infer_is_positive=True` only for a target domain that is truly nonnegative.
115
A positive observed window does not establish that temperature anomalies,
116
returns or residuals cannot become negative. Monotonic quantiles and a
117
continuous quantile head do not establish interval calibration.
118
119
## CSV helper
120
121
```bash
122
python scripts/forecast_csv.py monthly_sales.csv \
123
--date-col date --freq MS --value-cols sales,revenue \
124
--horizon 12 --batch-size 1 --nonnegative --output forecasts.csv
125
```
126
127
`forecast_csv.py` validates before loading, sorts dates, rejects duplicate
128
headers/dates, checks the complete regular grid and preserves missing positions.
129
Missing values fail by default; `--missing interpolate` fills only internal gaps,
130
never leading/trailing values. Without `--date-col`, row order is assumed to be
131
the regular grid and output uses steps. Numeric IDs must be excluded using
132
`--value-cols`. `--max-context` controls history truncation; `--horizon` is limited
133
to 1..1,024 for this quantile-head workflow.
134
135
Outputs retain `forecast`, `median`, `lower_80`, `upper_80`, `lower_60`, `upper_60`.
136
A `.metadata.json` sidecar records origin, cadence, model revision and config.
137
Old skill releases mislabeled q10-q90/q20-q80 as 90%/80%; migrate old outer
138
`*_90` to `*_80` and old inner `*_80` to `*_60` simultaneously. Old generated
139
example forecasts were removed because their mapping/provenance was invalid.
140
141
## Covariates and anomaly screening
142
143
For 2.5 XReg, compile `return_backcast=True`, retain targets and covariates on
144
identical grids and provide dynamic covariates over context **and** horizon.
145
`"xreg + timesfm"` fits regression on targets, then forecasts regression residuals.
146
`"timesfm + xreg"` forecasts first, then fits regression on backcast residuals.
147
The latter needs more than one input patch (32 observations). In package 3.0.2,
148
the implementation returns **lists of combined point and quantile forecasts**;
149
an inherited docstring incorrectly describes the second return as XReg-only.
150
See [references/api_reference.md](references/api_reference.md) for the complete call.
151
152
Quantile exceedances may screen for unusual observations, but even calibrated
153
80% intervals exclude about 20% of ordinary observations marginally. They do
154
not supply anomaly probabilities, familywise control or validated alarm severity.
155
Retrospective detrended Z scores also differ from prospective anomaly detection.
156
157
## References and examples
158
159
- [API reference](references/api_reference.md): 2.5 loader, compile, forecast and XReg contracts.
160
- [Output/config](references/output_and_config.md): all real ForecastConfig fields and interval indexing.
161
- [Data preparation](references/data_preparation.md): grid, missingness, covariate timing and format recipes.
162
- [Workflows](references/workflows.md): held-out and rolling-origin validation, baseline comparisons.
163
- [System requirements](references/system_requirements.md): resource checks and backend requirements.
164
- [Performance tuning](references/performance_tuning.md): measured batch/context tuning.
165
- [Examples and validation](references/examples_and_validation.md): example commands and testing scope.
166
- [TimesFM 3.0](references/timesfm3.md): multivariate API, 9-decile layout and usage boundary.
167
168
Primary review sources: [official source](https://github.com/google-research/timesfm),
169
[3.0.2 distribution](https://pypi.org/project/timesfm/3.0.2/),
170
[2.5 model card](https://huggingface.co/google/timesfm-2.5-200m-pytorch),
171
[3.0 model card](https://huggingface.co/google/timesfm-3.0-pytorch).
172

© Clayton Young / Superior Byte Works, LLC (@borealBytes) · Apache 2.0 · source · posted by @OpenSourceBuffGuy on promptparty.com

@OpenSourceBuffGuy

I find openly licensed prompts and post them here.

0 followers · 14,621 prompts

More by @OpenSourceBuffGuy

See all
Sea turtle carrying floating film studio island prompt image

Sea turtle carrying floating film studio island

Draws a giant sea turtle carrying a floating island film studio through a starry sky, where fairies polish rough film strips into golden film.

image-prompt, nano-banana, 3d-render, cartoon, fantasy-world, creatures, animals, whimsical, dreamy, cinematic, dramatic-lighting, vibrant-colors, bokeh, miniature, widescreen, night-scene, illustration, concept-art, surreal, storytelling, clay-3d

Desert buggy escapes drones past industrial outpost prompt image

Desert buggy escapes drones past industrial outpost

Builds a 15-second desert chase video where a racer in an armored buggy escapes drones past an industrial outpost, using five reference images with set jobs.

video-prompt, hailuo, action, multi-shot, timed-beats, camera-movement, reference-image, character-consistency, negative-prompt, cinematic, sci-fi, cars, landscape, aerial-view, tracking-shot, photorealistic, sound-effects, structured-output, long-form, widescreen

1 view
Cozy Pixel Art Farm Island Village prompt image

Cozy Pixel Art Farm Island Village

Draws a cozy 16-bit pixel-art farming village across six small islands joined by bridges, with exact counts for buildings, animals and crops.

image-prompt, gpt-image, pixel-art, isometric, game-assets, concept-art, maps, worldbuilding, cozy, vibrant-colors, ocean, landscape, wide-shot, widescreen, game-development, video-games, structured-output, whimsical, summer, high-angle, aerial-view, animals, negative-prompt, cityscape

1 view

Reviews

Loading reviews…

Discussion

Loading comments…