Timesfm Forecasting
K-DenseCommunityCreated by Clayton Young / Superior Byte Works, LLC (@borealBytes)Distributed by K-Dense
- Skill
- Tool integration
- Data and AI
- MIT
- Low risk
- Has scripts
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured workflow for performing zero-shot time-series forecasting using Google's TimesFM model. It supports both the Apache-licensed 2.5 checkpoint and the 3.0 multivariate API. The skill includes robust data preparation utilities for CSV files, handling of regular-grid validation, quantile forecasting, and integration of exogenous regressors (XReg). It emphasizes scientific rigor by requiring explicit validation of time grids, proper handling of missing data, and independent evaluation across rolling origins.
What it does
- Performs zero-shot time-series forecasting without task-specific training.
- Provides a CSV helper for automated data validation, sorting, and grid checking.
- Supports quantile forecasting to estimate uncertainty intervals.
- Integrates exogenous covariates (XReg) for improved forecasting accuracy.
- Facilitates held-out and rolling-origin evaluation workflows.
- Documents specific requirements for TimesFM 2.5 and 3.0 model versions.
When to use it
- When you need to forecast ordered temporal data without training a custom model.
- When you require uncertainty quantification via quantile outputs.
- When you have exogenous variables (covariates) that influence your target series.
- When you need to perform rigorous backtesting or rolling-origin evaluation.
- When working with structured time-series data in CSV or array formats.
Advantages
- Enables zero-shot forecasting, reducing the need for extensive model training.
- Includes built-in validation to ensure data integrity and regular time grids.
- Supports both point and probabilistic (quantile) forecasts.
- Provides clear guidance on version-specific licensing and API differences.
- Includes robust tooling for handling missing values and covariate alignment.
Usage examples
- “Forecast the next 12 months of sales from monthly_sales.csv using TimesFM 2.5.”
- The skill validates the CSV structure, prepares the inputs, and generates a forecast file containing point estimates and quantile intervals.
- “How do I include holiday schedules as covariates in my TimesFM forecast?”
- The skill provides a pattern for passing dynamic categorical covariates to the forecast_with_covariates method, ensuring alignment with the target history.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/k-dense-ai/timesfm-forecasting/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip timesfm-forecasting.zip -d .agents/skills
Documentation by Clayton Young / Superior Byte Works, LLC (@borealBytes)
TimesFM Forecasting
Choose the model/API first
The Python package version is 3.0.2; checkpoint versions are separate.
| Checkpoint | Interface | Quantile output | Usage terms |
|---|---|---|---|
| 2.5, 200M | timesfm.TimesFM_2p5_200M_torch, compile, forecast | mean + 9 deciles, median index 5 | Apache-2.0 weights; bundled CLI default |
| 3.0, about 330M | timesfm3.TimesFM3Forecaster, predict / predict_batch | 9 deciles, median index 4 | Downloaded weights restricted to non-commercial, non-production use |
Upstream identifies 3.0 as the latest model. This skill retains 2.5 as its default local workflow because its Apache-licensed weights have different usage terms. For 3.0 multivariate targets, past-only covariates or Apple MLX, read references/timesfm3.md before adapting code. Authorized Google Cloud services have separate terms; a Cloud entitlement does not change the license of downloaded weights. See the upstream license notice.
Use TimesFM for forecasting an ordered temporal target without task-specific model training. It is not a causal effect estimator, clinical detector, or physics-based climate model. Zero-shot describes fitting; it does not establish absence of benchmark overlap in pretraining or good accuracy in a new domain.
Workflow
Establish cadence, units, forecast origin, horizon, known-at-origin covariates, evaluation cutoffs and a naive/seasonal-naive baseline.
Validate a sorted, unique, regular time grid. Do not
dropna()internal gaps: that changes temporal spacing. Reject nonfinite inputs, or explicitly impute inside each training history. Never fill using held-out future targets.Run
python scripts/check_system.pybefore downloading/loading weights. Its available-RAM and cache-volume thresholds are heuristics, not a guarantee against OOM. Start with batch size 1; measure actual peak usage.Load the chosen checkpoint with a recorded immutable revision. For 2.5, compile explicit positive context/horizon settings; zero does not mean “use the maximum.” Keep patch-rounded context + horizon <=16,384 and horizon <=1,024 when using the continuous quantile head.
Forecast, validate shapes/finite values/quantile ordering and export the forecast origin, frequency, configuration and checkpoint revision.
Evaluate across rolling origins with preprocessing fitted independently per origin. Report accuracy, interval coverage and interval width by horizon; label quantile intervals nominal until calibrated on relevant data.
Installation
Run in a separate environment. The commands below target the reviewed release. Shell extras and version constraints must be quoted, particularly in zsh.
uv venv .venv-timesfm
uv pip install --python .venv-timesfm/bin/python "timesfm[torch]==3.0.2" numpy pandas
.venv-timesfm/bin/python scripts/check_system.pyUse the current PyTorch installation selector
for a CUDA wheel matching the host. The 2.5 loader in this release chooses
cuda:0 if CUDA exists, otherwise CPU; detecting MPS does not enable MPS
inference. Do not use model.to(...) on the wrapper as if it were an nn.Module.
For CPU-only XReg, install jax and scikit-learn alongside the PyTorch profile;
the upstream [xreg] extra requests jax[cuda], which is not appropriate for macOS.
Flax is a separate optional backend; it is not required by the bundled scripts.
from importlib.metadata import version
import timesfm
print(version("timesfm")) # package has no guaranteed timesfm.__version__
assert hasattr(timesfm, "TimesFM_2p5_200M_torch")TimesFM 2.5 quick start
The checkpoint-load examples are illustrative: validation of this refresh used native package code with tiny random models and controlled decode fixtures, without downloading pretrained weights. That verifies mechanics, not accuracy.
import numpy as np
import timesfm
model = timesfm.TimesFM_2p5_200M_torch.from_pretrained(
"google/timesfm-2.5-200m-pytorch",
revision="1d952420fba87f3c6dee4f240de0f1a0fbc790e3",
torch_compile=False, # avoid compilation startup during an initial smoke run
)
model.compile(timesfm.ForecastConfig(
max_context=512, max_horizon=128, per_core_batch_size=1,
normalize_inputs=True, use_continuous_quantile_head=True,
force_flip_invariance=True, infer_is_positive=False,
fix_quantile_crossing=True,
))
histories = [np.sin(np.linspace(0, 20, 200)).astype(np.float32)]
# 2.5 may append dummy series to its input list during batching; pass a fresh list.
point, q = model.forecast(horizon=24, inputs=list(histories))
assert point.shape == (1, 24) and q.shape == (1, 24, 10)
assert np.isfinite(q).all() and np.all(np.diff(q[..., 1:], axis=-1) >= 0)
assert np.allclose(point, q[..., 5])
lower_80, upper_80 = q[..., 1], q[..., 9] # q10-q90: nominal 80% PI
lower_60, upper_60 = q[..., 2], q[..., 8] # q20-q80: nominal 60% PISet infer_is_positive=True only for a target domain that is truly nonnegative.
A positive observed window does not establish that temperature anomalies,
returns or residuals cannot become negative. Monotonic quantiles and a
continuous quantile head do not establish interval calibration.
CSV helper
python scripts/forecast_csv.py monthly_sales.csv \
--date-col date --freq MS --value-cols sales,revenue \
--horizon 12 --batch-size 1 --nonnegative --output forecasts.csvforecast_csv.py validates before loading, sorts dates, rejects duplicate
headers/dates, checks the complete regular grid and preserves missing positions.
Missing values fail by default; --missing interpolate fills only internal gaps,
never leading/trailing values. Without --date-col, row order is assumed to be
the regular grid and output uses steps. Numeric IDs must be excluded using
--value-cols. --max-context controls history truncation; --horizon is limited
to 1..1,024 for this quantile-head workflow.
Outputs retain forecast, median, lower_80, upper_80, lower_60, upper_60.
A .metadata.json sidecar records origin, cadence, model revision and config.
Old skill releases mislabeled q10-q90/q20-q80 as 90%/80%; migrate old outer
*_90 to *_80 and old inner *_80 to *_60 simultaneously. Old generated
example forecasts were removed because their mapping/provenance was invalid.
Covariates and anomaly screening
For 2.5 XReg, compile return_backcast=True, retain targets and covariates on
identical grids and provide dynamic covariates over context and horizon.
"xreg + timesfm" fits regression on targets, then forecasts regression residuals.
"timesfm + xreg" forecasts first, then fits regression on backcast residuals.
The latter needs more than one input patch (32 observations). In package 3.0.2,
the implementation returns lists of combined point and quantile forecasts;
an inherited docstring incorrectly describes the second return as XReg-only.
See references/api_reference.md for the complete call.
Quantile exceedances may screen for unusual observations, but even calibrated 80% intervals exclude about 20% of ordinary observations marginally. They do not supply anomaly probabilities, familywise control or validated alarm severity. Retrospective detrended Z scores also differ from prospective anomaly detection.
References and examples
API reference: 2.5 loader, compile, forecast and XReg contracts.
Output/config: all real ForecastConfig fields and interval indexing.
Data preparation: grid, missingness, covariate timing and format recipes.
Workflows: held-out and rolling-origin validation, baseline comparisons.
System requirements: resource checks and backend requirements.
Performance tuning: measured batch/context tuning.
Examples and validation: example commands and testing scope.
TimesFM 3.0: multivariate API, 9-decile layout and usage boundary.
Primary review sources: official source, 3.0.2 distribution, 2.5 model card, 3.0 model card.
Files
- ATTRIBUTION.mdAdded by AutoGineer1.0 KiB
- LICENSELicence file added by AutoGineer1.0 KiB
- SKILL.md9.3 KiB
- examples/anomaly-detection/detect_anomalies.pyScript17.5 KiB
- examples/covariates-forecasting/demo_covariates.pyScript18.6 KiB
- examples/global-temperature/README.md1.7 KiB
- examples/global-temperature/generate_animation_data.pyScript2.6 KiB
- examples/global-temperature/generate_gif.pyScript7.2 KiB
- examples/global-temperature/generate_html.pyScript21.4 KiB
- examples/global-temperature/run_example.shScript435 B
- examples/global-temperature/run_forecast.pyScript2.6 KiB
- examples/global-temperature/temperature_anomaly.csv591 B
- examples/global-temperature/visualize_forecast.pyScript3.8 KiB
- references/api_reference.md6.1 KiB
- references/data_preparation.md3.4 KiB
- references/examples_and_validation.md3.1 KiB
- references/output_and_config.md2.3 KiB
- references/performance_tuning.md1.7 KiB
- references/system_requirements.md3.1 KiB
- references/timesfm3.md4.2 KiB
- references/workflows.md2.7 KiB
- scripts/check_system.pyScript16.5 KiB
- scripts/forecast_csv.pyScript11.0 KiB
references/timesfm3.md
TimesFM 3.0: distinct API and output layout
Reviewed package 3.0.2 against the released distribution and official source. The 3.0 checkpoint adds joint multivariate targets and native covariates. Its weights use the TimesFM Non-Commercial License: downloaded/self-hosted weights are restricted to non-commercial, non-production use. Authorized Google Cloud use has separate service terms. The code remains Apache-2.0; do not confuse that code license with the weight license.
PyTorch
Illustrative pretrained load; a tiny random model's native CPU save/load/predict was tested, not the downloaded 330M checkpoint or its predictive performance.
import numpy as np
from timesfm3 import TimesFM3Forecaster
forecaster = TimesFM3Forecaster.from_pretrained(
"google/timesfm-3.0-pytorch",
revision="43046b85ec22d584a13f8098c2ed39c889e129c2",
device="cpu", per_core_batch_size=1,
)
history = np.sin(np.linspace(0, 20, 128)).astype(np.float32)
out = forecaster.predict(history, horizon=24, return_quantiles=True)
assert out.forecast.shape == (24,)
assert out.quantiles.shape == (24, 9)
assert np.allclose(out.forecast, out.quantiles[:, 4])
lower_80, upper_80 = out.quantiles[:, 0], out.quantiles[:, 8]There is no 2.5-style compile(ForecastConfig) step. TimesFM3Evaluator(ModelConfig(...))
is another public wrapper; prefer the forecaster interface shown here for local
array inference. Hub options include revision, cache_dir, force_download,
local_files_only and token; cache/download semantics follow Hugging Face Hub.
Never print credentials. A local save_pretrained directory is also accepted.
Multivariate targets and covariates
T, H = 128, 24
rng = np.random.default_rng(7)
target = rng.normal(size=(2, T)).astype(np.float32)
past_only = rng.normal(size=(1, T)).astype(np.float32)
# Illustrative planned feature; in real evaluation all H values must be known at origin.
past_future = np.sin(np.arange(T + H) / 7)[None, :].astype(np.float32)
out = forecaster.predict(
target, horizon=H,
past_only_covariates=past_only,
past_future_covariates=past_future,
return_quantiles=True,
make_positive=False, sort_quantiles=True,
use_symmetric_averaging=False, use_znorm=False, padding_mode="none",
)
assert out.forecast.shape == (2, H)
assert out.quantiles.shape == (2, H, 9)Targets use (target_variates, time); covariates use (feature_channels, time).
Past-only time length is T; past-future length is T+H. All channels share the
same regular grid. Validate finite values, nonempty targets, positive H, lengths
and known-at-origin availability yourself; permissive interpolation is not a
missingness model. Covariates are numerical arrays; this is not the 2.5 static/
categorical XReg dictionary API.
predict_batch(contexts=[...], horizon=H, ...) yields ForecastOutput objects.
Parallel optional lists are past_only_covariates, past_future_covariates and
ts_ids. All contexts in a batch must have the same number of target variates;
keep 1D/2D conventions consistent. return_quantiles=False yields quantiles=None.
Default output contains q10..q90 only, so median is index 4 and there is no mean
slot. Sorting quantiles enforces order, not calibration.
The context cap is 15,360 with the official 32-point patch; older points are
truncated. Horizon is rounded internally to 64-point patches and sliced back
on output. padding_mode="none" avoids inventing future feature values; "edge"
extends covariates for internal patch padding. make_positive=False is the
default; enable it only if the target domain cannot be negative.
MLX / Apple silicon
Upstream package 3.0.2 offers timesfm[mlx] (MLX >=0.32):
from timesfm3.mlx import TimesFM3Forecaster, with corresponding from_pretrained,
predict and predict_batch. This is separate from the 2.5 torch wrapper's CPU
fallback on Apple hardware. MLX mechanics/performance were source-reviewed but
not executed in this refresh. Do not extrapolate published hardware benchmarks
to the user's context length, horizon or memory budget.
Requirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Declares allowed tools, Needs Python
The author says: 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+.
Security
What our scanner noticed· Low risk
- Instructions that use the network
- Scripts that your agent may run
This skill includes scripts that your agent may run. Read them before you use it.
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Created by
- Clayton Young / Superior Byte Works, LLC (@borealBytes)
- Publisher
- K-Dense (Community)
- Distributed by
- K-Dense
- Source
- K-Dense-AI/scientific-agent-skills · skills/timesfm-forecasting · commit a25cf9e
- Licence
- MIT License (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE.md)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by Clayton Young / Superior Byte Works, LLC (@borealBytes) or K-Dense.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download timesfm-forecasting.zip