Timesfm forecasting

Zero-shot time series forecasting with Google's TimesFM foundation model.

How to use it

  1. Hit Copy SKILL.md — or use the Claude Code line below to get every file.
  2. Claude: ⋯ → Download .md, then Customize → Skills → Add → Upload skill.
    ChatGPT: make a Project and paste it into Instructions.
    Neither? Paste it at the top of a new chat — it works for that chat.
  3. Describe your job in plain words. The AI follows the skill from there.
Claude Code — installs the whole folder, not just SKILL.md
npx degit K-Dense-AI/scientific-agent-skills/skills/timesfm-forecasting#main ~/.claude/skills/timesfm-forecasting

For one project only, change the path to .claude/skills/timesfm-forecasting. This skill also uses check_system.py — copying SKILL.md alone won't be enough. See the folder on GitHub.

Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Show the full text409 lines
timesfm-forecasting/SKILL.md409 lines15.2 KBpushed 52d agoRawView on GitHub

TimesFM Forecasting

Overview

TimesFM (Time Series Foundation Model) is a pretrained decoder-only foundation model developed by Google Research for time-series forecasting. It works zero-shot — feed it any univariate time series and it returns point forecasts with calibrated quantile prediction intervals, no training required.

This skill wraps TimesFM for safe, agent-friendly local inference. It includes a mandatory preflight system checker that verifies RAM, GPU memory, and disk space before the model is ever loaded so the agent never crashes a user's machine.

Key numbers: TimesFM 2.5 uses 200M parameters (~800 MB on disk, ~1.5 GB in RAM on CPU, ~1 GB VRAM on GPU). The archived v1/v2 500M-parameter model needs ~32 GB RAM. Always run the system checker first.

When to Use This Skill

Use this skill when:

  • Forecasting any univariate time series (sales, demand, sensor, vitals, price, weather)
  • You need zero-shot forecasting without training a custom model
  • You want probabilistic forecasts with calibrated prediction intervals (quantiles)
  • You have time series of any length (the model handles 1–16,384 context points)
  • You need to batch-forecast hundreds or thousands of series efficiently
  • You want a foundation model approach instead of hand-tuning ARIMA/ETS parameters

Do not use this skill when:

  • You need classical statistical models with coefficient interpretation → use statsmodels
  • You need time series classification or clustering → use aeon
  • You need multivariate vector autoregression or Granger causality → use statsmodels
  • Your data is tabular (not temporal) → use scikit-learn

Note on Anomaly Detection: TimesFM does not have built-in anomaly detection, but you can use the quantile forecasts as prediction intervals — values outside the 90% CI (q10–q90) are statistically unusual. See the examples/anomaly-detection/ directory for a full example.

⚠️ Mandatory Preflight: System Requirements Check

CRITICAL — ALWAYS run the system checker before loading the model for the first time.

python scripts/check_system.py

This script checks:

  1. Available RAM — warns if below 4 GB, blocks if below 2 GB
  2. GPU availability — detects CUDA/MPS devices and VRAM
  3. Disk space — verifies room for the ~800 MB model download
  4. Python version — requires 3.10+
  5. Existing installation — checks if timesfm and torch are installed

Note: Model weights are NOT stored in this repository. TimesFM weights (~800 MB) download on-demand from HuggingFace on first use and cache in ~/.cache/huggingface/. The preflight checker ensures sufficient resources before any download begins.

flowchart TD
    accTitle: Preflight System Check
    accDescr: Decision flowchart showing the system requirement checks that must pass before loading TimesFM.

    start["🚀 Run check_system.py"] --> ram{"RAM ≥ 4 GB?"}
    ram -->|"Yes"| gpu{"GPU available?"}
    ram -->|"No (2-4 GB)"| warn_ram["⚠️ Warning: tight RAM<br/>CPU-only, small batches"]
    ram -->|"No (< 2 GB)"| block["🛑 BLOCKED<br/>Insufficient memory"]
    warn_ram --> disk
    gpu -->|"CUDA / MPS"| vram{"VRAM ≥ 2 GB?"}
    gpu -->|"CPU only"| cpu_ok["✅ CPU mode<br/>Slower but works"]
    vram -->|"Yes"| gpu_ok["✅ GPU mode<br/>Fast inference"]
    vram -->|"No"| cpu_ok
    gpu_ok --> disk{"Disk ≥ 2 GB free?"}
    cpu_ok --> disk
    disk -->|"Yes"| ready["✅ READY<br/>Safe to load model"]
    disk -->|"No"| block_disk["🛑 BLOCKED<br/>Need space for weights"]

    classDef ok fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
    classDef warn fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
    classDef block fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
    classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937

    class ready,gpu_ok,cpu_ok ok
    class warn_ram warn
    class block,block_disk block
    class start,ram,gpu,vram,disk neutral

Hardware Requirements by Model Version

Model Parameters RAM (CPU) VRAM (GPU) Disk Context
TimesFM 2.5 (recommended) 200M ≥ 4 GB ≥ 2 GB ~800 MB up to 16,384
TimesFM 2.0 (archived) 500M ≥ 16 GB ≥ 8 GB ~2 GB up to 2,048
TimesFM 1.0 (archived) 200M ≥ 8 GB ≥ 4 GB ~800 MB up to 2,048

Recommendation: Always use TimesFM 2.5 unless you have a specific reason to use an older checkpoint. It is smaller, faster, and supports 8× longer context.

🔧 Installation

Step 1: Verify System (always first)

python scripts/check_system.py

Step 2: Install TimesFM

# Using uv (recommended by this repo)
uv pip install timesfm[torch]

# For JAX/Flax backend (faster on TPU/GPU)
uv pip install timesfm[flax]

Step 3: Install PyTorch for Your Hardware

# CUDA 12.1 (NVIDIA GPU)
uv pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cu121

# CPU only
uv pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cpu

# Apple Silicon (MPS)
uv pip install torch>=2.0.0  # MPS support is built-in

Step 4: Verify Installation

import timesfm
import numpy as np
print(f"TimesFM version: {timesfm.__version__}")
print("Installation OK")

🎯 Quick Start

Minimal Example (5 Lines)

import torch, numpy as np, timesfm

torch.set_float32_matmul_precision("high")

model = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
    "google/timesfm-2.5-200m-pytorch"
)
model.compile(timesfm.ForecastConfig(
    max_context=1024, max_horizon=256, normalize_inputs=True,
    use_continuous_quantile_head=True, force_flip_invariance=True,
    infer_is_positive=True, fix_quantile_crossing=True,
))

point, quantiles = model.forecast(horizon=24, inputs=[
    np.sin(np.linspace(0, 20, 200)),  # any 1-D array
])
# point.shape == (1, 24)        — median forecast
# quantiles.shape == (1, 24, 10) — 10th–90th percentile bands

Forecast from CSV

import pandas as pd, numpy as np

df = pd.read_csv("monthly_sales.csv", parse_dates=["date"], index_col="date")

# Convert each column to a list of arrays
inputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]

point, quantiles = model.forecast(horizon=12, inputs=inputs)

# Build a results DataFrame
for i, col in enumerate(df.columns):
    last_date = df[col].dropna().index[-1]
    future_dates = pd.date_range(last_date, periods=13, freq="MS")[1:]
    forecast_df = pd.DataFrame({
        "date": future_dates,
        "forecast": point[i],
        "lower_80": quantiles[i, :, 2],  # 20th percentile
        "upper_80": quantiles[i, :, 8],  # 80th percentile
    })
    print(f"\n--- {col} ---")
    print(forecast_df.to_string(index=False))

Forecast with Covariates (XReg)

TimesFM 2.5+ supports exogenous variables through forecast_with_covariates(). Requires timesfm[xreg].

# Requires: uv pip install timesfm[xreg]
point, quantiles = model.forecast_with_covariates(
    inputs=inputs,
    dynamic_numerical_covariates={"price": price_arrays},
    dynamic_categorical_covariates={"holiday": holiday_arrays},
    static_categorical_covariates={"region": region_labels},
    xreg_mode="xreg + timesfm",  # or "timesfm + xreg"
)
Covariate Type Description Example
dynamic_numerical Time-varying numeric price, temperature, promotion spend
dynamic_categorical Time-varying categorical holiday flag, day of week
static_numerical Per-series numeric store size, account age
static_categorical Per-series categorical store type, region, product category

XReg Modes:

  • "xreg + timesfm" (default): TimesFM forecasts first, then XReg adjusts residuals
  • "timesfm + xreg": XReg fits first, then TimesFM forecasts residuals

See examples/covariates-forecasting/ for a complete example with synthetic retail data.

Anomaly Detection (via Quantile Intervals)

TimesFM does not have built-in anomaly detection, but the quantile forecasts naturally provide prediction intervals that can detect anomalies:

point, q = model.forecast(horizon=H, inputs=[values])

# 90% prediction interval
lower_90 = q[0, :, 1]  # 10th percentile
upper_90 = q[0, :, 9]  # 90th percentile

# Detect anomalies: values outside the 90% CI
actual = test_values  # your holdout data
anomalies = (actual < lower_90) | (actual > upper_90)

# Severity levels
is_warning = (actual < q[0, :, 2]) | (actual > q[0, :, 8])  # outside 80% CI
is_critical = anomalies  # outside 90% CI
Severity Condition Interpretation
Normal Inside 80% CI Expected behavior
Warning Outside 80% CI Unusual but possible
Critical Outside 90% CI Statistically rare (< 10% probability)

See examples/anomaly-detection/ for a complete example with visualization.

# Requires: uv pip install timesfm[xreg]
point, quantiles = model.forecast_with_covariates(
    inputs=inputs,
    dynamic_numerical_covariates={"temperature": temp_arrays},
    dynamic_categorical_covariates={"day_of_week": dow_arrays},
    static_categorical_covariates={"region": region_labels},
    xreg_mode="xreg + timesfm",  # or "timesfm + xreg"
)

Output, Configuration, Workflows, and Tuning

  • references/output_and_config.md: reading the point forecast and the 10 quantile bands, deriving prediction intervals, and every ForecastConfig field.
  • references/workflows.md: the standard forecast sequence, many-series forecasting from a wide CSV, and backtesting with interval coverage.
  • references/performance_tuning.md: GPU and TF32 setup, per_core_batch_size by available memory, and memory management.
  • references/examples_and_validation.md: runnable examples, the quality checklist, common mistakes, and regression checks.

🔗 Integration with Other Skills

With statsmodels

Use statsmodels for classical models (ARIMA, SARIMAX) as a comparison baseline:

# TimesFM forecast
tfm_point, tfm_q = model.forecast(horizon=H, inputs=[values])

# statsmodels ARIMA forecast
from statsmodels.tsa.arima.model import ARIMA
arima = ARIMA(values, order=(1,1,1)).fit()
arima_forecast = arima.forecast(steps=H)

# Compare
print(f"TimesFM MAE: {np.mean(np.abs(actual - tfm_point[0])):.2f}")
print(f"ARIMA MAE:   {np.mean(np.abs(actual - arima_forecast)):.2f}")

With matplotlib / scientific-visualization

Plot forecasts with prediction intervals as publication-quality figures.

With exploratory-data-analysis

Run EDA on the time series before forecasting to understand trends, seasonality, and stationarity.

📚 Available Scripts

scripts/check_system.py

Mandatory preflight checker. Run before first model load.

python scripts/check_system.py

Output example:

=== TimesFM System Requirements Check ===

[RAM]       Total: 32.0 GB | Available: 24.3 GB  ✅ PASS
[GPU]       NVIDIA RTX 4090 | VRAM: 24.0 GB      ✅ PASS
[Disk]      Free: 142.5 GB                        ✅ PASS
[Python]    3.12.1                                 ✅ PASS
[timesfm]   Installed (2.5.0)                      ✅ PASS
[torch]     Installed (2.4.1+cu121)                ✅ PASS

VERDICT: ✅ System is ready for TimesFM 2.5 (GPU mode)
Recommended: per_core_batch_size=128

scripts/forecast_csv.py

End-to-end CSV forecasting with automatic system check.

python scripts/forecast_csv.py input.csv \
    --horizon 24 \
    --date-col date \
    --value-cols sales,revenue \
    --output forecasts.csv

📖 Reference Documentation

Detailed guides in references/:

File Contents
references/system_requirements.md Hardware tiers, GPU/CPU selection, memory estimation formulas
references/api_reference.md Full ForecastConfig docs, from_pretrained options, output shapes
references/data_preparation.md Input formats, NaN handling, CSV loading, covariate setup

Common Pitfalls

  1. Not running system check → model load crashes on low-RAM machines. Always run check_system.py first.
  2. Forgetting model.compile()RuntimeError: Model is not compiled. Must call compile() before forecast().
  3. Not setting normalize_inputs=True → unstable forecasts for series with large values.
  4. Using v1/v2 on machines with < 32 GB RAM → use TimesFM 2.5 (200M params) instead.
  5. Not setting fix_quantile_crossing=True → quantiles may not be monotonic (q10 > q50).
  6. Huge per_core_batch_size on small GPU → CUDA OOM. Start small, increase.
  7. Passing 2-D arrays → TimesFM expects a list of 1-D arrays, not a 2-D matrix.
  8. Forgetting torch.set_float32_matmul_precision("high") → slower inference on Ampere+ GPUs.
  9. Not handling NaN in output → edge cases with very short series. Always check np.isnan(point).any().
  10. Using infer_is_positive=True for series that can be negative → clamps forecasts at zero. Set False for temperature, returns, etc.

Model Versions

timeline
    accTitle: TimesFM Version History
    accDescr: Timeline of TimesFM model releases showing parameter counts and key improvements.

    section 2024
        TimesFM 1.0 : 200M params, 2K context, JAX only
        TimesFM 2.0 : 500M params, 2K context, PyTorch + JAX
    section 2025
        TimesFM 2.5 : 200M params, 16K context, quantile head, no frequency indicator
Version Params Context Quantile Head Frequency Flag Status
2.5 200M 16,384 ✅ Continuous (30M) ❌ Removed Latest
2.0 500M 2,048 ✅ Fixed buckets ✅ Required Archived
1.0 200M 2,048 ✅ Fixed buckets ✅ Required Archived

Hugging Face checkpoints:

  • google/timesfm-2.5-200m-pytorch (recommended)
  • google/timesfm-2.5-200m-flax
  • google/timesfm-2.0-500m-pytorch (archived)
  • google/timesfm-1.0-200m-pytorch (archived)

Resources

1---
2name: timesfm-forecasting
3description: Zero-shot time series forecasting with Google's TimesFM foundation model. Use for any univariate time series (sales, sensors, energy, vitals, weather) without training a custom model. Supports CSV/DataFrame/array inputs with point forecasts and prediction intervals. Includes a preflight system checker script to verify RAM/GPU before first use.
4allowed-tools: Read Write Edit Bash
5license: Apache-2.0 license
6metadata:
7 version: "1.2"
8 skill-author: Clayton Young / Superior Byte Works, LLC (@borealBytes)
9 skill-version: 1.0.0
10---
11 
12# TimesFM Forecasting
13 
14## Overview
15 
16TimesFM (Time Series Foundation Model) is a pretrained decoder-only foundation model
17developed by Google Research for time-series forecasting. It works **zero-shot** — feed it
18any univariate time series and it returns point forecasts with calibrated quantile
19prediction intervals, no training required.
20 
21This skill wraps TimesFM for safe, agent-friendly local inference. It includes a
22**mandatory preflight system checker** that verifies RAM, GPU memory, and disk space
23before the model is ever loaded so the agent never crashes a user's machine.
24 
25> **Key numbers**: TimesFM 2.5 uses 200M parameters (~800 MB on disk, ~1.5 GB in RAM on
26> CPU, ~1 GB VRAM on GPU). The archived v1/v2 500M-parameter model needs ~32 GB RAM.
27> Always run the system checker first.
28 
29## When to Use This Skill
30 
31Use this skill when:
32 
33- Forecasting **any univariate time series** (sales, demand, sensor, vitals, price, weather)
34- You need **zero-shot forecasting** without training a custom model
35- You want **probabilistic forecasts** with calibrated prediction intervals (quantiles)
36- You have time series of **any length** (the model handles 1–16,384 context points)
37- You need to **batch-forecast** hundreds or thousands of series efficiently
38- You want a **foundation model** approach instead of hand-tuning ARIMA/ETS parameters
39 
40Do **not** use this skill when:
41 
42- You need classical statistical models with coefficient interpretation → use `statsmodels`
43- You need time series classification or clustering → use `aeon`
44- You need multivariate vector autoregression or Granger causality → use `statsmodels`
45- Your data is tabular (not temporal) → use `scikit-learn`
46 
47> **Note on Anomaly Detection**: TimesFM does not have built-in anomaly detection, but you can
48> use the **quantile forecasts as prediction intervals** — values outside the 90% CI (q10–q90)
49> are statistically unusual. See the `examples/anomaly-detection/` directory for a full example.
50 
51## ⚠️ Mandatory Preflight: System Requirements Check
52 
53**CRITICAL — ALWAYS run the system checker before loading the model for the first time.**
54 
55```bash
56python scripts/check_system.py
57```
58 
59This script checks:
60 
611. **Available RAM** — warns if below 4 GB, blocks if below 2 GB
622. **GPU availability** — detects CUDA/MPS devices and VRAM
633. **Disk space** — verifies room for the ~800 MB model download
644. **Python version** — requires 3.10+
655. **Existing installation** — checks if `timesfm` and `torch` are installed
66 
67> **Note:** Model weights are **NOT stored in this repository**. TimesFM weights (~800 MB)
68> download on-demand from HuggingFace on first use and cache in `~/.cache/huggingface/`.
69> The preflight checker ensures sufficient resources before any download begins.
70 
71```mermaid
72flowchart TD
73 accTitle: Preflight System Check
74 accDescr: Decision flowchart showing the system requirement checks that must pass before loading TimesFM.
75 
76 start["🚀 Run check_system.py"] --> ram{"RAM ≥ 4 GB?"}
77 ram -->|"Yes"| gpu{"GPU available?"}
78 ram -->|"No (2-4 GB)"| warn_ram["⚠️ Warning: tight RAM<br/>CPU-only, small batches"]
79 ram -->|"No (< 2 GB)"| block["🛑 BLOCKED<br/>Insufficient memory"]
80 warn_ram --> disk
81 gpu -->|"CUDA / MPS"| vram{"VRAM ≥ 2 GB?"}
82 gpu -->|"CPU only"| cpu_ok["✅ CPU mode<br/>Slower but works"]
83 vram -->|"Yes"| gpu_ok["✅ GPU mode<br/>Fast inference"]
84 vram -->|"No"| cpu_ok
85 gpu_ok --> disk{"Disk ≥ 2 GB free?"}
86 cpu_ok --> disk
87 disk -->|"Yes"| ready["✅ READY<br/>Safe to load model"]
88 disk -->|"No"| block_disk["🛑 BLOCKED<br/>Need space for weights"]
89 
90 classDef ok fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d
91 classDef warn fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12
92 classDef block fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d
93 classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937
94 
95 class ready,gpu_ok,cpu_ok ok
96 class warn_ram warn
97 class block,block_disk block
98 class start,ram,gpu,vram,disk neutral
99```
100 
101### Hardware Requirements by Model Version
102 
103| Model | Parameters | RAM (CPU) | VRAM (GPU) | Disk | Context |
104| ----- | ---------- | --------- | ---------- | ---- | ------- |
105| **TimesFM 2.5** (recommended) | 200M | ≥ 4 GB | ≥ 2 GB | ~800 MB | up to 16,384 |
106| TimesFM 2.0 (archived) | 500M | ≥ 16 GB | ≥ 8 GB | ~2 GB | up to 2,048 |
107| TimesFM 1.0 (archived) | 200M | ≥ 8 GB | ≥ 4 GB | ~800 MB | up to 2,048 |
108 
109> **Recommendation**: Always use TimesFM 2.5 unless you have a specific reason to use an
110> older checkpoint. It is smaller, faster, and supports 8× longer context.
111 
112## 🔧 Installation
113 
114### Step 1: Verify System (always first)
115 
116```bash
117python scripts/check_system.py
118```
119 
120### Step 2: Install TimesFM
121 
122```bash
123# Using uv (recommended by this repo)
124uv pip install timesfm[torch]
125 
126# For JAX/Flax backend (faster on TPU/GPU)
127uv pip install timesfm[flax]
128```
129 
130### Step 3: Install PyTorch for Your Hardware
131 
132```bash
133# CUDA 12.1 (NVIDIA GPU)
134uv pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cu121
135 
136# CPU only
137uv pip install torch>=2.0.0 --index-url https://download.pytorch.org/whl/cpu
138 
139# Apple Silicon (MPS)
140uv pip install torch>=2.0.0 # MPS support is built-in
141```
142 
143### Step 4: Verify Installation
144 
145```python
146import timesfm
147import numpy as np
148print(f"TimesFM version: {timesfm.__version__}")
149print("Installation OK")
150```
151 
152## 🎯 Quick Start
153 
154### Minimal Example (5 Lines)
155 
156```python
157import torch, numpy as np, timesfm
158 
159torch.set_float32_matmul_precision("high")
160 
161model = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
162 "google/timesfm-2.5-200m-pytorch"
163)
164model.compile(timesfm.ForecastConfig(
165 max_context=1024, max_horizon=256, normalize_inputs=True,
166 use_continuous_quantile_head=True, force_flip_invariance=True,
167 infer_is_positive=True, fix_quantile_crossing=True,
168))
169 
170point, quantiles = model.forecast(horizon=24, inputs=[
171 np.sin(np.linspace(0, 20, 200)), # any 1-D array
172])
173# point.shape == (1, 24) — median forecast
174# quantiles.shape == (1, 24, 10) — 10th–90th percentile bands
175```
176 
177### Forecast from CSV
178 
179```python
180import pandas as pd, numpy as np
181 
182df = pd.read_csv("monthly_sales.csv", parse_dates=["date"], index_col="date")
183 
184# Convert each column to a list of arrays
185inputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]
186 
187point, quantiles = model.forecast(horizon=12, inputs=inputs)
188 
189# Build a results DataFrame
190for i, col in enumerate(df.columns):
191 last_date = df[col].dropna().index[-1]
192 future_dates = pd.date_range(last_date, periods=13, freq="MS")[1:]
193 forecast_df = pd.DataFrame({
194 "date": future_dates,
195 "forecast": point[i],
196 "lower_80": quantiles[i, :, 2], # 20th percentile
197 "upper_80": quantiles[i, :, 8], # 80th percentile
198 })
199 print(f"\n--- {col} ---")
200 print(forecast_df.to_string(index=False))
201```
202 
203### Forecast with Covariates (XReg)
204 
205TimesFM 2.5+ supports exogenous variables through `forecast_with_covariates()`. Requires `timesfm[xreg]`.
206 
207```python
208# Requires: uv pip install timesfm[xreg]
209point, quantiles = model.forecast_with_covariates(
210 inputs=inputs,
211 dynamic_numerical_covariates={"price": price_arrays},
212 dynamic_categorical_covariates={"holiday": holiday_arrays},
213 static_categorical_covariates={"region": region_labels},
214 xreg_mode="xreg + timesfm", # or "timesfm + xreg"
215)
216```
217 
218| Covariate Type | Description | Example |
219| -------------- | ----------- | ------- |
220| `dynamic_numerical` | Time-varying numeric | price, temperature, promotion spend |
221| `dynamic_categorical` | Time-varying categorical | holiday flag, day of week |
222| `static_numerical` | Per-series numeric | store size, account age |
223| `static_categorical` | Per-series categorical | store type, region, product category |
224 
225**XReg Modes:**
226- `"xreg + timesfm"` (default): TimesFM forecasts first, then XReg adjusts residuals
227- `"timesfm + xreg"`: XReg fits first, then TimesFM forecasts residuals
228 
229> See `examples/covariates-forecasting/` for a complete example with synthetic retail data.
230 
231### Anomaly Detection (via Quantile Intervals)
232 
233TimesFM does not have built-in anomaly detection, but the **quantile forecasts naturally provide
234prediction intervals** that can detect anomalies:
235 
236```python
237point, q = model.forecast(horizon=H, inputs=[values])
238 
239# 90% prediction interval
240lower_90 = q[0, :, 1] # 10th percentile
241upper_90 = q[0, :, 9] # 90th percentile
242 
243# Detect anomalies: values outside the 90% CI
244actual = test_values # your holdout data
245anomalies = (actual < lower_90) | (actual > upper_90)
246 
247# Severity levels
248is_warning = (actual < q[0, :, 2]) | (actual > q[0, :, 8]) # outside 80% CI
249is_critical = anomalies # outside 90% CI
250```
251 
252| Severity | Condition | Interpretation |
253| -------- | --------- | -------------- |
254| **Normal** | Inside 80% CI | Expected behavior |
255| **Warning** | Outside 80% CI | Unusual but possible |
256| **Critical** | Outside 90% CI | Statistically rare (< 10% probability) |
257 
258> See `examples/anomaly-detection/` for a complete example with visualization.
259 
260```python
261# Requires: uv pip install timesfm[xreg]
262point, quantiles = model.forecast_with_covariates(
263 inputs=inputs,
264 dynamic_numerical_covariates={"temperature": temp_arrays},
265 dynamic_categorical_covariates={"day_of_week": dow_arrays},
266 static_categorical_covariates={"region": region_labels},
267 xreg_mode="xreg + timesfm", # or "timesfm + xreg"
268)
269```
270 
271## Output, Configuration, Workflows, and Tuning
272 
273- [references/output_and_config.md](references/output_and_config.md): reading the point
274 forecast and the 10 quantile bands, deriving prediction intervals, and every
275 `ForecastConfig` field.
276- [references/workflows.md](references/workflows.md): the standard forecast sequence,
277 many-series forecasting from a wide CSV, and backtesting with interval coverage.
278- [references/performance_tuning.md](references/performance_tuning.md): GPU and TF32
279 setup, `per_core_batch_size` by available memory, and memory management.
280- [references/examples_and_validation.md](references/examples_and_validation.md):
281 runnable examples, the quality checklist, common mistakes, and regression checks.
282 
283## 🔗 Integration with Other Skills
284 
285### With `statsmodels`
286 
287Use `statsmodels` for classical models (ARIMA, SARIMAX) as a **comparison baseline**:
288 
289```python
290# TimesFM forecast
291tfm_point, tfm_q = model.forecast(horizon=H, inputs=[values])
292 
293# statsmodels ARIMA forecast
294from statsmodels.tsa.arima.model import ARIMA
295arima = ARIMA(values, order=(1,1,1)).fit()
296arima_forecast = arima.forecast(steps=H)
297 
298# Compare
299print(f"TimesFM MAE: {np.mean(np.abs(actual - tfm_point[0])):.2f}")
300print(f"ARIMA MAE: {np.mean(np.abs(actual - arima_forecast)):.2f}")
301```
302 
303### With `matplotlib` / `scientific-visualization`
304 
305Plot forecasts with prediction intervals as publication-quality figures.
306 
307### With `exploratory-data-analysis`
308 
309Run EDA on the time series before forecasting to understand trends, seasonality, and stationarity.
310 
311 
312 
313 
314 
315## 📚 Available Scripts
316 
317### `scripts/check_system.py`
318 
319**Mandatory preflight checker.** Run before first model load.
320 
321```bash
322python scripts/check_system.py
323```
324 
325Output example:
326```
327=== TimesFM System Requirements Check ===
328 
329[RAM] Total: 32.0 GB | Available: 24.3 GB ✅ PASS
330[GPU] NVIDIA RTX 4090 | VRAM: 24.0 GB ✅ PASS
331[Disk] Free: 142.5 GB ✅ PASS
332[Python] 3.12.1 ✅ PASS
333[timesfm] Installed (2.5.0) ✅ PASS
334[torch] Installed (2.4.1+cu121) ✅ PASS
335 
336VERDICT: ✅ System is ready for TimesFM 2.5 (GPU mode)
337Recommended: per_core_batch_size=128
338```
339 
340### `scripts/forecast_csv.py`
341 
342End-to-end CSV forecasting with automatic system check.
343 
344```bash
345python scripts/forecast_csv.py input.csv \
346 --horizon 24 \
347 --date-col date \
348 --value-cols sales,revenue \
349 --output forecasts.csv
350```
351 
352## 📖 Reference Documentation
353 
354Detailed guides in `references/`:
355 
356| File | Contents |
357| ---- | -------- |
358| `references/system_requirements.md` | Hardware tiers, GPU/CPU selection, memory estimation formulas |
359| `references/api_reference.md` | Full `ForecastConfig` docs, `from_pretrained` options, output shapes |
360| `references/data_preparation.md` | Input formats, NaN handling, CSV loading, covariate setup |
361 
362## Common Pitfalls
363 
3641. **Not running system check** → model load crashes on low-RAM machines. Always run `check_system.py` first.
3652. **Forgetting `model.compile()`**`RuntimeError: Model is not compiled`. Must call `compile()` before `forecast()`.
3663. **Not setting `normalize_inputs=True`** → unstable forecasts for series with large values.
3674. **Using v1/v2 on machines with < 32 GB RAM** → use TimesFM 2.5 (200M params) instead.
3685. **Not setting `fix_quantile_crossing=True`** → quantiles may not be monotonic (q10 > q50).
3696. **Huge `per_core_batch_size` on small GPU** → CUDA OOM. Start small, increase.
3707. **Passing 2-D arrays** → TimesFM expects a **list of 1-D arrays**, not a 2-D matrix.
3718. **Forgetting `torch.set_float32_matmul_precision("high")`** → slower inference on Ampere+ GPUs.
3729. **Not handling NaN in output** → edge cases with very short series. Always check `np.isnan(point).any()`.
37310. **Using `infer_is_positive=True` for series that can be negative** → clamps forecasts at zero. Set False for temperature, returns, etc.
374 
375## Model Versions
376 
377```mermaid
378timeline
379 accTitle: TimesFM Version History
380 accDescr: Timeline of TimesFM model releases showing parameter counts and key improvements.
381 
382 section 2024
383 TimesFM 1.0 : 200M params, 2K context, JAX only
384 TimesFM 2.0 : 500M params, 2K context, PyTorch + JAX
385 section 2025
386 TimesFM 2.5 : 200M params, 16K context, quantile head, no frequency indicator
387```
388 
389| Version | Params | Context | Quantile Head | Frequency Flag | Status |
390| ------- | ------ | ------- | ------------- | -------------- | ------ |
391| **2.5** | 200M | 16,384 | ✅ Continuous (30M) | ❌ Removed | **Latest** |
392| 2.0 | 500M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |
393| 1.0 | 200M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |
394 
395**Hugging Face checkpoints:**
396 
397- `google/timesfm-2.5-200m-pytorch` (recommended)
398- `google/timesfm-2.5-200m-flax`
399- `google/timesfm-2.0-500m-pytorch` (archived)
400- `google/timesfm-1.0-200m-pytorch` (archived)
401 
402## Resources
403 
404- **Paper**: [A Decoder-Only Foundation Model for Time-Series Forecasting](https://arxiv.org/abs/2310.10688) (ICML 2024)
405- **Repository**: https://github.com/google-research/timesfm
406- **Hugging Face**: https://huggingface.co/collections/google/timesfm-release-66e4be5fdb56e960c1e482a6
407- **Google Blog**: https://research.google/blog/a-decoder-only-foundation-model-for-time-series-forecasting/
408- **BigQuery Integration**: https://cloud.google.com/bigquery/docs/timesfm-model
409 

Discussion

Alternatives

Also in Research data
Analytical method validationPlan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include "method validation", "analytical method validation", "AMV", "validation protocol", "acceptance criteria", "linearity", "reportable range", "accuracy and precision", "repeatability", "intermediate precision", "recovery", "LOD", "LOQ", "detection limit", "quantitation limit", "specificity", "robustness", "method transfer", "method comparison", "Deming", "Passing-Bablok", "Bland-Altman", "equivalence testing", "OOS investigation", "ICH Q2", "Q2(R2)", "Q14", "USP 1225", "ICH M10", "incurred sample reanalysis", "ISR", "CLSI EP", and any request to show that an assay works.Science · MITAutoskillObserve the user's screen via screenpipe, detect repeated research workflows, match them against existing scientific-agent-skills, and draft new skills (or composition recipes that chain existing ones) for the patterns not yet covered. Use when the user asks to analyze their recent work and propose skills based on what they actually do. Requires the screenpipe daemon (https://github.com/screenpipe/screenpipe) running locally on port 3030 — the skill has no other data source and will refuse to run if screenpipe is unreachable. All detection runs locally; only redacted cluster summaries reach the LLM.Science · MITBioservicesUnified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.Science · MITDatabase lookupQuery documented public database APIs with explicit endpoints, filters, pagination, and provenance. Use when a scientific, regulatory, financial, or other database-backed fact must be retrieved reproducibly from a named source rather than inferred from general knowledge.Science · MIT