Skip to content

philogicae/timesfm_notebooks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timesfm_notebooks

Forecast any time series with Google's TimesFM 2.5-200M — median path with a ±0.5-quantile confidence band.

TimesFM forecast chart

Notebooks

Notebook Data Horizon
Colab timesfm.ipynb noisy sine + sawtooth 12
Colab timesfm_crypto.ipynb BTC / ETH via yfinance 250 (~750d)
Colab timesfm_weather.ipynb temperature via Open-Meteo 254 (~10.5d)

All share the same 22-cell pipeline (Global · Data · Execution) — only the Data section differs. The template uses an identity transform; the crypto notebook uses residual-space (Signal = log_return / vol, to_levels = last * exp(cumsum(fcst * vol))); the weather notebook uses an identity transform on raw temperatures.


Quick start

  1. Click Open in Colab on timesfm.ipynb above

  2. Bottom-center → click the Gemini icon → select Gemini 3 Flash

  3. Tell it what to forecast. It fetches the data, edits the Sources cell, runs the notebook.

    Examples:

    • Weather"Pull hourly temperature for Tokyo last year from Open-Meteo and forecast the next 2 weeks"
    • Sales"Load my Q1–Q3 daily sales CSV from /content/sales.csv and forecast Q4"
    • Web traffic"Fetch daily pageviews for wikipedia.org from the Wikimedia API and forecast 30 days"
  4. Chart + confidence band renders inline · PNG saved for GitHub

⚠️ Works great on most time series. Crypto is hard — the timesfm_crypto.ipynb example is a demo, not financial advice.

Manual run

Open in Colab (T4 GPU, preconfigured) → Run all. Model loads once, final cell runs the pipeline:

[1/3] Loaded 2 series: BTC-USD, ETH-USD (0.4s)
[2/3] Preparing + inference... done (0.7s)
[3/3] Rendering chart... ✓ total 6.9s

Chart PNG is saved and embedded in the notebook, so it renders on GitHub without re-executing.


Fork

A source returns dict[str, pd.Series] with a DatetimeIndex. prepare_all turns each into a DataFrame with Level (history) + Signal (what TimesFM sees). Swap the Sources block, add series to PARAMS, rest runs unchanged.

PARAMS = {
    'symbols': [...],
    'resample_rule': '3D',
    'horizon': 250,
    'colors': {...},
    'labels': {...},
}

Details

  • Modelgoogle/timesfm-2.5-200m-pytorch · max_context=1024 · max_horizon=256
  • Quantiles — median (q=5) ± 0.5 band (q=4.5 / q=5.5), interpolated across 10 heads
  • Chart — 1280×720 log-scale dual-axis Plotly, custom axis labels, dashed median, shaded band, rangeslider
  • Depstimesfm, plotly>=6.1.1, plotly-geo, kaleido, pandas, numpy + Chrome/kaleido headless setup (inline) · crypto adds yfinance
  • Runtime — HuggingFace weights at runtime · GPU via notebook metadata (gpuType: T4, Python 3.10)

About

TimesFM 2.5-200M forecasting notebooks

Resources

Stars

Watchers

Forks

Contributors