forecast-web
v1.0.0
Published
Forecasting and tabular prediction models in the browser on WebGPU or WebAssembly: TimesFM 2.5, Chronos-Bolt and TabICL. Optional React hook.
Maintainers
Readme
forecast-web
Time series forecasting, anomaly detection and tabular prediction that run entirely in the browser. Give it a history, get back a forecast with uncertainty bands; give it a table, get back predictions with no training. Inference runs on the visitor's machine, on WebGPU when available and WASM otherwise. No server, and no data leaves the page.
Documentation · Live demo · Changelog
npm install forecast-webForecast
import { loadForecaster } from "forecast-web";
const model = await loadForecaster({ model: "timesfm-2.5" });
const dailySignups = [412, 398, 455, 470, 433, 390, 401 /* ... oldest first */];
const [forecast] = await model.forecast([dailySignups], { horizon: 30 });
forecast.median; // 30 numbers: the point forecast
forecast.q10; // lower edge of the 80% range
forecast.q90; // upper edgeA series is any array of numbers, oldest first, one value per evenly spaced step; use null for gaps. Shaping your data shows CSV files, API records, raw events and typed arrays.
Find anomalies
const { anomalies } = await model.detectAnomalies(hourlyRequests);
for (const a of anomalies) console.log(`point ${a.index}: ${a.value}, expected about ${a.expected}`);Each point is compared with what the model expected from the history before it, using thresholds tuned per model. Anomalies guide
Predict from a table
import { loadTabular } from "forecast-web/tabular";
const clf = await loadTabular({ task: "classification" });
const fitted = clf.fit(trainRows, trainLabels); // rows of numbers, text, booleans or null
const labels = await fitted.predict(newRows);TabICLv2 reads the training rows in context, so fit is instant. Regression works the same way with task: "regression". Tabular guide
React
import { ForecastProvider, useForecaster } from "forecast-web/react";
<ForecastProvider model="chronos-bolt-small">
<SignupsChart />
</ForecastProvider>;
function SignupsChart() {
const { status, forecast } = useForecaster(); // loads the model on first use
// ...
}Models
| Model | id | Download (default) | Notes |
|---|---|---|---|
| TimesFM 2.5, Google Research | "timesfm-2.5" | 463 MB WebGPU, 261 MB WASM | Default. Reads 512 points, forecasts up to 128 steps |
| Chronos-Bolt Tiny, Mini, Small, Base, Amazon | "chronos-bolt-tiny" ... "chronos-bolt-base" | 18, 43, 96, 411 MB | Reads 2048 points, forecasts up to 512 steps |
| TabICLv2, Inria | forecast-web/tabular | 56 to 59 MB | Up to 10 classes, 5,000 rows, 100 features |
Every model is checked against its official Python library, and weights are downloaded once, verified against hashes in the package, and cached. Models guide
Learn more
- Getting started: install, a first forecast, and shaping real data.
- Forecasting: options, horizons, caching and errors.
- Deployment: bundlers, self-hosting the weights, browser support.
- Troubleshooting: backends, slow loads, memory, CORS and common errors.
- Versioning: what may change in minor and major releases.
- API reference, and every published version on jsDocs.io.
Runs in desktop Chrome, Edge and Safari: CI tests every change in Chromium and WebKit, and Firefox and phones are not tested yet. Node support is planned for a minor release.
License
Apache-2.0. TimesFM is by Google Research and Chronos by Amazon, both Apache-2.0. TabICL is by the Soda team at Inria under BSD-3-Clause. See NOTICE. Contributions welcome; see CONTRIBUTING.md.
