[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JA422PDY72X1Z7795V01R3":3,"skill-same:01M6JA422PDY72X1Z7795V01R3":81},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":46,"linkOnly":47,"markdownContent":48,"markdownBody":49,"frontMatter":50,"refName":60,"commitSha":61,"skillDirectory":62,"forksCount":54,"repositoryHtmlUrl":63,"repositoryHomepageUrl":6,"ownerHtmlUrl":64,"ownerBlogUrl":65,"ownerDescription":66,"updatedAt":67,"install":68,"resources":80},"01M6JA422PDY72X1Z7795V01R3","science-timesfm-forecasting",null,"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\u002FDataFrame\u002Farray inputs with point forecasts and prediction intervals. Includes a preflight system checker script to verify RAM\u002FGPU before first use.","Flissel\u002Fvibemind-os","Flissel","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F104565236?v=4","01M6J8Q88NWAJGKPC5TEG9YCNV","Felix Baumann","01M6J8Q8D7XAFY44P70XTJFZBW",1,"MIT","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fskills\u002Fscience\u002Ftimesfm-forecasting\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45],"science timesfm forecasting","science","forecasting","timesfm forecasting","foundation","2026","prediction","custom","vitals","source","for","checker","time series forecasting","Zero-Shot","series","time","google","use","repo","model","system","preflight","ZeRO","time series","dataframe","training","weather","2026-11-10 10:12:30",false,"---\nname: science-timesfm-forecasting\ndescription: Zero-shot time series forecasting with Google's TimesFM foundation model.\n  Use for any univariate time series (sales, sensors, energy, vitals, weather) without\n  training a custom model. Supports CSV\u002FDataFrame\u002Farray inputs with point forecasts\n  and prediction intervals. Includes a preflight system checker script to verify RAM\u002FGPU\n  before first use.\napp: science\nrequires_approval: true\nagents:\n- '*'\ninputs: []\nexpected_state:\n  description: Imported skill — behavior matches source repo\n  verification_tool: none\nconfidence: 1.0\nattempts: 0\nsuccesses: 0\nlast_adjusted: '2026-05-11T21:21:45+00:00'\n---\n\n# TimesFM Forecasting\n\n## Overview\n\nTimesFM (Time Series Foundation Model) is a pretrained decoder-only foundation model\ndeveloped by Google Research for time-series forecasting. It works **zero-shot** — feed it\nany univariate time series and it returns point forecasts with calibrated quantile\nprediction intervals, no training required.\n\nThis skill wraps TimesFM for safe, agent-friendly local inference. It includes a\n**mandatory preflight system checker** that verifies RAM, GPU memory, and disk space\nbefore the model is ever loaded so the agent never crashes a user's machine.\n\n> **Key numbers**: TimesFM 2.5 uses 200M parameters (~800 MB on disk, ~1.5 GB in RAM on\n> CPU, ~1 GB VRAM on GPU). The archived v1\u002Fv2 500M-parameter model needs ~32 GB RAM.\n> Always run the system checker first.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Forecasting **any univariate time series** (sales, demand, sensor, vitals, price, weather)\n- You need **zero-shot forecasting** without training a custom model\n- You want **probabilistic forecasts** with calibrated prediction intervals (quantiles)\n- You have time series of **any length** (the model handles 1–16,384 context points)\n- You need to **batch-forecast** hundreds or thousands of series efficiently\n- You want a **foundation model** approach instead of hand-tuning ARIMA\u002FETS parameters\n\nDo **not** use this skill when:\n\n- You need classical statistical models with coefficient interpretation → use `statsmodels`\n- You need time series classification or clustering → use `aeon`\n- You need multivariate vector autoregression or Granger causality → use `statsmodels`\n- Your data is tabular (not temporal) → use `scikit-learn`\n\n> **Note on Anomaly Detection**: TimesFM does not have built-in anomaly detection, but you can\n> use the **quantile forecasts as prediction intervals** — values outside the 90% CI (q10–q90)\n> are statistically unusual. See the `examples\u002Fanomaly-detection\u002F` directory for a full example.\n\n## ⚠️ Mandatory Preflight: System Requirements Check\n\n**CRITICAL — ALWAYS run the system checker before loading the model for the first time.**\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\nThis script checks:\n\n1. **Available RAM** — warns if below 4 GB, blocks if below 2 GB\n2. **GPU availability** — detects CUDA\u002FMPS devices and VRAM\n3. **Disk space** — verifies room for the ~800 MB model download\n4. **Python version** — requires 3.10+\n5. **Existing installation** — checks if `timesfm` and `torch` are installed\n\n> **Note:** Model weights are **NOT stored in this repository**. TimesFM weights (~800 MB)\n> download on-demand from HuggingFace on first use and cache in `~\u002F.cache\u002Fhuggingface\u002F`.\n> The preflight checker ensures sufficient resources before any download begins.\n\n```mermaid\nflowchart TD\n    accTitle: Preflight System Check\n    accDescr: Decision flowchart showing the system requirement checks that must pass before loading TimesFM.\n\n    start[\"? Run check_system.py\"] --> ram{\"RAM ≥ 4 GB?\"}\n    ram -->|\"Yes\"| gpu{\"GPU available?\"}\n    ram -->|\"No (2-4 GB)\"| warn_ram[\"⚠️ Warning: tight RAM\u003Cbr\u002F>CPU-only, small batches\"]\n    ram -->|\"No (\u003C 2 GB)\"| block[\"? BLOCKED\u003Cbr\u002F>Insufficient memory\"]\n    warn_ram --> disk\n    gpu -->|\"CUDA \u002F MPS\"| vram{\"VRAM ≥ 2 GB?\"}\n    gpu -->|\"CPU only\"| cpu_ok[\"✅ CPU mode\u003Cbr\u002F>Slower but works\"]\n    vram -->|\"Yes\"| gpu_ok[\"✅ GPU mode\u003Cbr\u002F>Fast inference\"]\n    vram -->|\"No\"| cpu_ok\n    gpu_ok --> disk{\"Disk ≥ 2 GB free?\"}\n    cpu_ok --> disk\n    disk -->|\"Yes\"| ready[\"✅ READY\u003Cbr\u002F>Safe to load model\"]\n    disk -->|\"No\"| block_disk[\"? BLOCKED\u003Cbr\u002F>Need space for weights\"]\n\n    classDef ok fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d\n    classDef warn fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12\n    classDef block fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d\n    classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937\n\n    class ready,gpu_ok,cpu_ok ok\n    class warn_ram warn\n    class block,block_disk block\n    class start,ram,gpu,vram,disk neutral\n```\n\n### Hardware Requirements by Model Version\n\n| Model | Parameters | RAM (CPU) | VRAM (GPU) | Disk | Context |\n| ----- | ---------- | --------- | ---------- | ---- | ------- |\n| **TimesFM 2.5** (recommended) | 200M | ≥ 4 GB | ≥ 2 GB | ~800 MB | up to 16,384 |\n| TimesFM 2.0 (archived) | 500M | ≥ 16 GB | ≥ 8 GB | ~2 GB | up to 2,048 |\n| TimesFM 1.0 (archived) | 200M | ≥ 8 GB | ≥ 4 GB | ~800 MB | up to 2,048 |\n\n> **Recommendation**: Always use TimesFM 2.5 unless you have a specific reason to use an\n> older checkpoint. It is smaller, faster, and supports 8× longer context.\n\n## ? Installation\n\n### Step 1: Verify System (always first)\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\n### Step 2: Install TimesFM\n\n```bash\n# Using uv (recommended by this repo)\nuv pip install timesfm[torch]\n\n# Or using pip\npip install timesfm[torch]\n\n# For JAX\u002FFlax backend (faster on TPU\u002FGPU)\nuv pip install timesfm[flax]\n```\n\n### Step 3: Install PyTorch for Your Hardware\n\n```bash\n# CUDA 12.1 (NVIDIA GPU)\npip install torch>=2.0.0 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu121\n\n# CPU only\npip install torch>=2.0.0 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\n\n# Apple Silicon (MPS)\npip install torch>=2.0.0  # MPS support is built-in\n```\n\n### Step 4: Verify Installation\n\n```python\nimport timesfm\nimport numpy as np\nprint(f\"TimesFM version: {timesfm.__version__}\")\nprint(\"Installation OK\")\n```\n\n## ? Quick Start\n\n### Minimal Example (5 Lines)\n\n```python\nimport torch, numpy as np, timesfm\n\ntorch.set_float32_matmul_precision(\"high\")\n\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\nmodel.compile(timesfm.ForecastConfig(\n    max_context=1024, max_horizon=256, normalize_inputs=True,\n    use_continuous_quantile_head=True, force_flip_invariance=True,\n    infer_is_positive=True, fix_quantile_crossing=True,\n))\n\npoint, quantiles = model.forecast(horizon=24, inputs=[\n    np.sin(np.linspace(0, 20, 200)),  # any 1-D array\n])\n# point.shape == (1, 24)        — median forecast\n# quantiles.shape == (1, 24, 10) — 10th–90th percentile bands\n```\n\n### Forecast from CSV\n\n```python\nimport pandas as pd, numpy as np\n\ndf = pd.read_csv(\"monthly_sales.csv\", parse_dates=[\"date\"], index_col=\"date\")\n\n# Convert each column to a list of arrays\ninputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]\n\npoint, quantiles = model.forecast(horizon=12, inputs=inputs)\n\n# Build a results DataFrame\nfor i, col in enumerate(df.columns):\n    last_date = df[col].dropna().index[-1]\n    future_dates = pd.date_range(last_date, periods=13, freq=\"MS\")[1:]\n    forecast_df = pd.DataFrame({\n        \"date\": future_dates,\n        \"forecast\": point[i],\n        \"lower_80\": quantiles[i, :, 2],  # 20th percentile\n        \"upper_80\": quantiles[i, :, 8],  # 80th percentile\n    })\n    print(f\"\\n--- {col} ---\")\n    print(forecast_df.to_string(index=False))\n```\n\n### Forecast with Covariates (XReg)\n\nTimesFM 2.5+ supports exogenous variables through `forecast_with_covariates()`. Requires `timesfm[xreg]`.\n\n```python\n# Requires: uv pip install timesfm[xreg]\npoint, quantiles = model.forecast_with_covariates(\n    inputs=inputs,\n    dynamic_numerical_covariates={\"price\": price_arrays},\n    dynamic_categorical_covariates={\"holiday\": holiday_arrays},\n    static_categorical_covariates={\"region\": region_labels},\n    xreg_mode=\"xreg + timesfm\",  # or \"timesfm + xreg\"\n)\n```\n\n| Covariate Type | Description | Example |\n| -------------- | ----------- | ------- |\n| `dynamic_numerical` | Time-varying numeric | price, temperature, promotion spend |\n| `dynamic_categorical` | Time-varying categorical | holiday flag, day of week |\n| `static_numerical` | Per-series numeric | store size, account age |\n| `static_categorical` | Per-series categorical | store type, region, product category |\n\n**XReg Modes:**\n- `\"xreg + timesfm\"` (default): TimesFM forecasts first, then XReg adjusts residuals\n- `\"timesfm + xreg\"`: XReg fits first, then TimesFM forecasts residuals\n\n> See `examples\u002Fcovariates-forecasting\u002F` for a complete example with synthetic retail data.\n\n### Anomaly Detection (via Quantile Intervals)\n\nTimesFM does not have built-in anomaly detection, but the **quantile forecasts naturally provide\nprediction intervals** that can detect anomalies:\n\n```python\npoint, q = model.forecast(horizon=H, inputs=[values])\n\n# 90% prediction interval\nlower_90 = q[0, :, 1]  # 10th percentile\nupper_90 = q[0, :, 9]  # 90th percentile\n\n# Detect anomalies: values outside the 90% CI\nactual = test_values  # your holdout data\nanomalies = (actual \u003C lower_90) | (actual > upper_90)\n\n# Severity levels\nis_warning = (actual \u003C q[0, :, 2]) | (actual > q[0, :, 8])  # outside 80% CI\nis_critical = anomalies  # outside 90% CI\n```\n\n| Severity | Condition | Interpretation |\n| -------- | --------- | -------------- |\n| **Normal** | Inside 80% CI | Expected behavior |\n| **Warning** | Outside 80% CI | Unusual but possible |\n| **Critical** | Outside 90% CI | Statistically rare (\u003C 10% probability) |\n\n> See `examples\u002Fanomaly-detection\u002F` for a complete example with visualization.\n\n```python\n# Requires: uv pip install timesfm[xreg]\npoint, quantiles = model.forecast_with_covariates(\n    inputs=inputs,\n    dynamic_numerical_covariates={\"temperature\": temp_arrays},\n    dynamic_categorical_covariates={\"day_of_week\": dow_arrays},\n    static_categorical_covariates={\"region\": region_labels},\n    xreg_mode=\"xreg + timesfm\",  # or \"timesfm + xreg\"\n)\n```\n\n## ? Understanding the Output\n\n### Quantile Forecast Structure\n\nTimesFM returns `(point_forecast, quantile_forecast)`:\n\n- **`point_forecast`**: shape `(batch, horizon)` — the median (0.5 quantile)\n- **`quantile_forecast`**: shape `(batch, horizon, 10)` — ten slices:\n\n| Index | Quantile | Use |\n| ----- | -------- | --- |\n| 0 | Mean | Average prediction |\n| 1 | 0.1 | Lower bound of 80% PI |\n| 2 | 0.2 | Lower bound of 60% PI |\n| 3 | 0.3 | — |\n| 4 | 0.4 | — |\n| **5** | **0.5** | **Median (= `point_forecast`)** |\n| 6 | 0.6 | — |\n| 7 | 0.7 | — |\n| 8 | 0.8 | Upper bound of 60% PI |\n| 9 | 0.9 | Upper bound of 80% PI |\n\n### Extracting Prediction Intervals\n\n```python\npoint, q = model.forecast(horizon=H, inputs=data)\n\n# 80% prediction interval (most common)\nlower_80 = q[:, :, 1]  # 10th percentile\nupper_80 = q[:, :, 9]  # 90th percentile\n\n# 60% prediction interval (tighter)\nlower_60 = q[:, :, 2]  # 20th percentile\nupper_60 = q[:, :, 8]  # 80th percentile\n\n# Median (same as point forecast)\nmedian = q[:, :, 5]\n```\n\n```mermaid\nflowchart LR\n    accTitle: Quantile Forecast Anatomy\n    accDescr: Diagram showing how the 10-element quantile vector maps to prediction intervals.\n\n    input[\"? Input Series\u003Cbr\u002F>1-D array\"] --> model[\"? TimesFM\u003Cbr\u002F>compile + forecast\"]\n    model --> point[\"? Point Forecast\u003Cbr\u002F>(batch, horizon)\"]\n    model --> quant[\"? Quantile Forecast\u003Cbr\u002F>(batch, horizon, 10)\"]\n    quant --> pi80[\"80% PI\u003Cbr\u002F>q[:,:,1] – q[:,:,9]\"]\n    quant --> pi60[\"60% PI\u003Cbr\u002F>q[:,:,2] – q[:,:,8]\"]\n    quant --> median[\"Median\u003Cbr\u002F>q[:,:,5]\"]\n\n    classDef data fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f\n    classDef model fill:#f3e8ff,stroke:#9333ea,stroke-width:2px,color:#581c87\n    classDef output fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d\n\n    class input data\n    class model model\n    class point,quant,pi80,pi60,median output\n```\n\n## ? ForecastConfig Reference\n\nAll forecasting behavior is controlled by `timesfm.ForecastConfig`:\n\n```python\ntimesfm.ForecastConfig(\n    max_context=1024,                    # Max context window (truncates longer series)\n    max_horizon=256,                     # Max forecast horizon\n    normalize_inputs=True,               # Normalize inputs (RECOMMENDED for stability)\n    per_core_batch_size=32,              # Batch size per device (tune for memory)\n    use_continuous_quantile_head=True,   # Better quantile accuracy for long horizons\n    force_flip_invariance=True,          # Ensures f(-x) = -f(x) (mathematical consistency)\n    infer_is_positive=True,              # Clamp forecasts ≥ 0 when all inputs > 0\n    fix_quantile_crossing=True,          # Ensure q10 ≤ q20 ≤ ... ≤ q90\n    return_backcast=False,               # Return backcast (for covariate workflows)\n)\n```\n\n| Parameter | Default | When to Change |\n| --------- | ------- | -------------- |\n| `max_context` | 0 | Set to match your longest historical window (e.g., 512, 1024, 4096) |\n| `max_horizon` | 0 | Set to your maximum forecast length |\n| `normalize_inputs` | False | **Always set True** — prevents scale-dependent instability |\n| `per_core_batch_size` | 1 | Increase for throughput; decrease if OOM |\n| `use_continuous_quantile_head` | False | **Set True** for calibrated prediction intervals |\n| `force_flip_invariance` | True | Keep True unless profiling shows it hurts |\n| `infer_is_positive` | True | Set False for series that can be negative (temperature, returns) |\n| `fix_quantile_crossing` | False | **Set True** to guarantee monotonic quantiles |\n\n## ? Common Workflows\n\n### Workflow 1: Single Series Forecast\n\n```mermaid\nflowchart TD\n    accTitle: Single Series Forecast Workflow\n    accDescr: Step-by-step workflow for forecasting a single time series with system checking.\n\n    check[\"1. Run check_system.py\"] --> load[\"2. Load model\u003Cbr\u002F>from_pretrained()\"]\n    load --> compile[\"3. Compile with ForecastConfig\"]\n    compile --> prep[\"4. Prepare data\u003Cbr\u002F>pd.read_csv → np.array\"]\n    prep --> forecast[\"5. model.forecast()\u003Cbr\u002F>horizon=N\"]\n    forecast --> extract[\"6. Extract point + PI\"]\n    extract --> plot[\"7. Plot or export results\"]\n\n    classDef step fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937\n    class check,load,compile,prep,forecast,extract,plot step\n```\n\n```python\nimport torch, numpy as np, pandas as pd, timesfm\n\n# 1. System check (run once)\n# python scripts\u002Fcheck_system.py\n\n# 2-3. Load and compile\ntorch.set_float32_matmul_precision(\"high\")\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\nmodel.compile(timesfm.ForecastConfig(\n    max_context=512, max_horizon=52, normalize_inputs=True,\n    use_continuous_quantile_head=True, fix_quantile_crossing=True,\n))\n\n# 4. Prepare data\ndf = pd.read_csv(\"weekly_demand.csv\", parse_dates=[\"week\"])\nvalues = df[\"demand\"].values.astype(np.float32)\n\n# 5. Forecast\npoint, quantiles = model.forecast(horizon=52, inputs=[values])\n\n# 6. Extract prediction intervals\nforecast_df = pd.DataFrame({\n    \"forecast\": point[0],\n    \"lower_80\": quantiles[0, :, 1],\n    \"upper_80\": quantiles[0, :, 9],\n})\n\n# 7. Plot\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots(figsize=(12, 5))\nax.plot(values[-104:], label=\"Historical\")\nx_fc = range(len(values[-104:]), len(values[-104:]) + 52)\nax.plot(x_fc, forecast_df[\"forecast\"], label=\"Forecast\", color=\"tab:orange\")\nax.fill_between(x_fc, forecast_df[\"lower_80\"], forecast_df[\"upper_80\"],\n                alpha=0.2, color=\"tab:orange\", label=\"80% PI\")\nax.legend()\nax.set_title(\"52-Week Demand Forecast\")\nplt.tight_layout()\nplt.savefig(\"forecast.png\", dpi=150)\nprint(\"Saved forecast.png\")\n```\n\n### Workflow 2: Batch Forecasting (Many Series)\n\n```python\nimport pandas as pd, numpy as np\n\n# Load wide-format CSV (one column per series)\ndf = pd.read_csv(\"all_stores.csv\", parse_dates=[\"date\"], index_col=\"date\")\ninputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]\n\n# Forecast all series at once (batched internally)\npoint, quantiles = model.forecast(horizon=30, inputs=inputs)\n\n# Collect results\nresults = {}\nfor i, col in enumerate(df.columns):\n    results[col] = {\n        \"forecast\": point[i].tolist(),\n        \"lower_80\": quantiles[i, :, 1].tolist(),\n        \"upper_80\": quantiles[i, :, 9].tolist(),\n    }\n\n# Export\nimport json\nwith open(\"batch_forecasts.json\", \"w\") as f:\n    json.dump(results, f, indent=2)\nprint(f\"Forecasted {len(results)} series → batch_forecasts.json\")\n```\n\n### Workflow 3: Evaluate Forecast Accuracy\n\n```python\nimport numpy as np\n\n# Hold out the last H points for evaluation\nH = 24\ntrain = values[:-H]\nactual = values[-H:]\n\npoint, quantiles = model.forecast(horizon=H, inputs=[train])\npred = point[0]\n\n# Metrics\nmae = np.mean(np.abs(actual - pred))\nrmse = np.sqrt(np.mean((actual - pred) ** 2))\nmape = np.mean(np.abs((actual - pred) \u002F actual)) * 100\n\n# Prediction interval coverage\nlower = quantiles[0, :, 1]\nupper = quantiles[0, :, 9]\ncoverage = np.mean((actual >= lower) & (actual \u003C= upper)) * 100\n\nprint(f\"MAE:  {mae:.2f}\")\nprint(f\"RMSE: {rmse:.2f}\")\nprint(f\"MAPE: {mape:.1f}%\")\nprint(f\"80% PI Coverage: {coverage:.1f}% (target: 80%)\")\n```\n\n## ⚙️ Performance Tuning\n\n### GPU Acceleration\n\n```python\nimport torch\n\n# Check GPU availability\nif torch.cuda.is_available():\n    print(f\"GPU: {torch.cuda.get_device_name(0)}\")\n    print(f\"VRAM: {torch.cuda.get_device_properties(0).total_mem \u002F 1e9:.1f} GB\")\nelif hasattr(torch.backends, \"mps\") and torch.backends.mps.is_available():\n    print(\"Apple Silicon MPS available\")\nelse:\n    print(\"CPU only — inference will be slower but still works\")\n\n# Always set this for Ampere+ GPUs (A100, RTX 3090, etc.)\ntorch.set_float32_matmul_precision(\"high\")\n```\n\n### Batch Size Tuning\n\n```python\n# Start conservative, increase until OOM\n# GPU with 8 GB VRAM:  per_core_batch_size=64\n# GPU with 16 GB VRAM: per_core_batch_size=128\n# GPU with 24 GB VRAM: per_core_batch_size=256\n# CPU with 8 GB RAM:   per_core_batch_size=8\n# CPU with 16 GB RAM:  per_core_batch_size=32\n# CPU with 32 GB RAM:  per_core_batch_size=64\n\nmodel.compile(timesfm.ForecastConfig(\n    max_context=1024,\n    max_horizon=256,\n    per_core_batch_size=32,  # \u003C-- tune this\n    normalize_inputs=True,\n    use_continuous_quantile_head=True,\n    fix_quantile_crossing=True,\n))\n```\n\n### Memory-Constrained Environments\n\n```python\nimport gc, torch\n\n# Force garbage collection before loading\ngc.collect()\nif torch.cuda.is_available():\n    torch.cuda.empty_cache()\n\n# Load model\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\n\n# Use small batch size on low-memory machines\nmodel.compile(timesfm.ForecastConfig(\n    max_context=512,        # Reduce context if needed\n    max_horizon=128,        # Reduce horizon if needed\n    per_core_batch_size=4,  # Small batches\n    normalize_inputs=True,\n    use_continuous_quantile_head=True,\n    fix_quantile_crossing=True,\n))\n\n# Process series in chunks to avoid OOM\nCHUNK = 50\nall_results = []\nfor i in range(0, len(inputs), CHUNK):\n    chunk = inputs[i:i+CHUNK]\n    p, q = model.forecast(horizon=H, inputs=chunk)\n    all_results.append((p, q))\n    gc.collect()  # Clean up between chunks\n```\n\n## ? Integration with Other Skills\n\n### With `statsmodels`\n\nUse `statsmodels` for classical models (ARIMA, SARIMAX) as a **comparison baseline**:\n\n```python\n# TimesFM forecast\ntfm_point, tfm_q = model.forecast(horizon=H, inputs=[values])\n\n# statsmodels ARIMA forecast\nfrom statsmodels.tsa.arima.model import ARIMA\narima = ARIMA(values, order=(1,1,1)).fit()\narima_forecast = arima.forecast(steps=H)\n\n# Compare\nprint(f\"TimesFM MAE: {np.mean(np.abs(actual - tfm_point[0])):.2f}\")\nprint(f\"ARIMA MAE:   {np.mean(np.abs(actual - arima_forecast)):.2f}\")\n```\n\n### With `matplotlib` \u002F `scientific-visualization`\n\nPlot forecasts with prediction intervals as publication-quality figures.\n\n### With `exploratory-data-analysis`\n\nRun EDA on the time series before forecasting to understand trends, seasonality, and stationarity.\n\n\n\n\n\n## ? Available Scripts\n\n### `scripts\u002Fcheck_system.py`\n\n**Mandatory preflight checker.** Run before first model load.\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\nOutput example:\n```\n=== TimesFM System Requirements Check ===\n\n[RAM]       Total: 32.0 GB | Available: 24.3 GB  ✅ PASS\n[GPU]       NVIDIA RTX 4090 | VRAM: 24.0 GB      ✅ PASS\n[Disk]      Free: 142.5 GB                        ✅ PASS\n[Python]    3.12.1                                 ✅ PASS\n[timesfm]   Installed (2.5.0)                      ✅ PASS\n[torch]     Installed (2.4.1+cu121)                ✅ PASS\n\nVERDICT: ✅ System is ready for TimesFM 2.5 (GPU mode)\nRecommended: per_core_batch_size=128\n```\n\n### `scripts\u002Fforecast_csv.py`\n\nEnd-to-end CSV forecasting with automatic system check.\n\n```bash\npython scripts\u002Fforecast_csv.py input.csv \\\n    --horizon 24 \\\n    --date-col date \\\n    --value-cols sales,revenue \\\n    --output forecasts.csv\n```\n\n## ? Reference Documentation\n\nDetailed guides in `references\u002F`:\n\n| File | Contents |\n| ---- | -------- |\n| `references\u002Fsystem_requirements.md` | Hardware tiers, GPU\u002FCPU selection, memory estimation formulas |\n| `references\u002Fapi_reference.md` | Full `ForecastConfig` docs, `from_pretrained` options, output shapes |\n| `references\u002Fdata_preparation.md` | Input formats, NaN handling, CSV loading, covariate setup |\n\n## Common Pitfalls\n\n1. **Not running system check** → model load crashes on low-RAM machines. Always run `check_system.py` first.\n2. **Forgetting `model.compile()`** → `RuntimeError: Model is not compiled`. Must call `compile()` before `forecast()`.\n3. **Not setting `normalize_inputs=True`** → unstable forecasts for series with large values.\n4. **Using v1\u002Fv2 on machines with \u003C 32 GB RAM** → use TimesFM 2.5 (200M params) instead.\n5. **Not setting `fix_quantile_crossing=True`** → quantiles may not be monotonic (q10 > q50).\n6. **Huge `per_core_batch_size` on small GPU** → CUDA OOM. Start small, increase.\n7. **Passing 2-D arrays** → TimesFM expects a **list of 1-D arrays**, not a 2-D matrix.\n8. **Forgetting `torch.set_float32_matmul_precision(\"high\")`** → slower inference on Ampere+ GPUs.\n9. **Not handling NaN in output** → edge cases with very short series. Always check `np.isnan(point).any()`.\n10. **Using `infer_is_positive=True` for series that can be negative** → clamps forecasts at zero. Set False for temperature, returns, etc.\n\n## Model Versions\n\n```mermaid\ntimeline\n    accTitle: TimesFM Version History\n    accDescr: Timeline of TimesFM model releases showing parameter counts and key improvements.\n\n    section 2024\n        TimesFM 1.0 : 200M params, 2K context, JAX only\n        TimesFM 2.0 : 500M params, 2K context, PyTorch + JAX\n    section 2025\n        TimesFM 2.5 : 200M params, 16K context, quantile head, no frequency indicator\n```\n\n| Version | Params | Context | Quantile Head | Frequency Flag | Status |\n| ------- | ------ | ------- | ------------- | -------------- | ------ |\n| **2.5** | 200M | 16,384 | ✅ Continuous (30M) | ❌ Removed | **Latest** |\n| 2.0 | 500M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |\n| 1.0 | 200M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |\n\n**Hugging Face checkpoints:**\n\n- `google\u002Ftimesfm-2.5-200m-pytorch` (recommended)\n- `google\u002Ftimesfm-2.5-200m-flax`\n- `google\u002Ftimesfm-2.0-500m-pytorch` (archived)\n- `google\u002Ftimesfm-1.0-200m-pytorch` (archived)\n\n## Resources\n\n- **Paper**: [A Decoder-Only Foundation Model for Time-Series Forecasting](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10688) (ICML 2024)\n- **Repository**: https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Ftimesfm\n- **Hugging Face**: https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fgoogle\u002Ftimesfm-release-66e4be5fdb56e960c1e482a6\n- **Google Blog**: https:\u002F\u002Fresearch.google\u002Fblog\u002Fa-decoder-only-foundation-model-for-time-series-forecasting\u002F\n- **BigQuery Integration**: https:\u002F\u002Fcloud.google.com\u002Fbigquery\u002Fdocs\u002Ftimesfm-model\n\n## Examples\n\nThree fully-working reference examples live in `examples\u002F`. Use them as ground truth for correct API usage and expected output shape.\n\n| Example | Directory | What It Demonstrates | When To Use It |\n| ------- | --------- | -------------------- | -------------- |\n| **Global Temperature Forecast** | `examples\u002Fglobal-temperature\u002F` | Basic `model.forecast()` call, CSV -> PNG -> GIF pipeline, 36-month NOAA context | Starting point; copy-paste baseline for any univariate series |\n| **Anomaly Detection** | `examples\u002Fanomaly-detection\u002F` | Two-phase detection: linear detrend + Z-score on context, quantile PI on forecast; 2-panel viz | Any task requiring outlier detection on historical + forecasted data |\n| **Covariates (XReg)** | `examples\u002Fcovariates-forecasting\u002F` | `forecast_with_covariates()` API (TimesFM 2.5), covariate decomposition, 2x2 shared-axis viz | Retail, energy, or any series with known exogenous drivers |\n\n### Running the Examples\n\n```bash\n# Global temperature (no TimesFM 2.5 needed)\ncd examples\u002Fglobal-temperature && python run_forecast.py && python visualize_forecast.py\n\n# Anomaly detection (uses TimesFM 1.0)\ncd examples\u002Fanomaly-detection && python detect_anomalies.py\n\n# Covariates (API demo -- requires TimesFM 2.5 + timesfm[xreg] for real inference)\ncd examples\u002Fcovariates-forecasting && python demo_covariates.py\n```\n\n### Expected Outputs\n\n| Example | Key output files | Acceptance criteria |\n| ------- | ---------------- | ------------------- |\n| global-temperature | `output\u002Fforecast_output.json`, `output\u002Fforecast_visualization.png` | `point_forecast` has 12 values; PNG shows context + forecast + PI bands |\n| anomaly-detection | `output\u002Fanomaly_detection.json`, `output\u002Fanomaly_detection.png` | Sep 2023 flagged CRITICAL (z >= 3.0); >= 2 forecast CRITICAL from injected anomalies |\n| covariates-forecasting | `output\u002Fsales_with_covariates.csv`, `output\u002Fcovariates_data.png` | CSV has 108 rows (3 stores x 36 weeks); stores have **distinct** price arrays |\n\n## Quality Checklist\n\nRun this checklist after every TimesFM task before declaring success:\n\n- [ ] **Output shape correct** -- `point_fc` shape is `(n_series, horizon)`, `quant_fc` is `(n_series, horizon, 10)`\n- [ ] **Quantile indices** -- index 0 = mean, 1 = q10, 2 = q20 ... 9 = q90. **NOT** 0 = q0, 1 = q10.\n- [ ] **Frequency flag** -- TimesFM 1.0\u002F2.0: pass `freq=[0]` for monthly data. TimesFM 2.5: no freq flag.\n- [ ] **Series length** -- context must be >= 32 data points (model minimum). Warn if shorter.\n- [ ] **No NaN** -- `np.isnan(point_fc).any()` should be False. Check input series for gaps first.\n- [ ] **Visualization axes** -- if multiple panels share data, use `sharex=True`. All time axes must cover the same span.\n- [ ] **Binary outputs in Git LFS** -- PNG and GIF files must be tracked via `.gitattributes` (repo root already configured).\n- [ ] **No large datasets committed** -- any real dataset > 1 MB should be downloaded to `tempfile.mkdtemp()` and annotated in code.\n- [ ] **`matplotlib.use('Agg')`** -- must appear before any pyplot import when running headless.\n- [ ] **`infer_is_positive`** -- set `False` for temperature anomalies, financial returns, or any series that can be negative.\n\n## Common Mistakes\n\nThese bugs have appeared in this skill's examples. Learn from them:\n\n1. **Quantile index off-by-one** -- The most common mistake. `quant_fc[..., 0]` is the **mean**, not q0. q10 = index 1, q90 = index 9. Always define named constants: `IDX_Q10, IDX_Q20, IDX_Q80, IDX_Q90 = 1, 2, 8, 9`.\n\n2. **Variable shadowing in comprehensions** -- If you build per-series covariate dicts inside a loop, do NOT use the loop variable as the comprehension variable. Accumulate into separate `dict[str, ndarray]` outside the loop, then assign.\n   ```python\n   # WRONG -- outer `store_id` gets shadowed:\n   covariates = {store_id: arr[store_id] for store_id in stores}  # inside outer loop over store_id\n   # CORRECT -- use a different name or accumulate beforehand:\n   prices_by_store: dict[str, np.ndarray] = {}\n   for store_id, config in stores.items():\n       prices_by_store[store_id] = compute_price(config)\n   ```\n\n3. **Wrong CSV column name** -- The global-temperature CSV uses `anomaly_c`, not `anomaly`. Always `print(df.columns)` before accessing.\n\n4. **`tight_layout()` warning with `sharex=True`** -- Harmless; suppress with `plt.tight_layout(rect=[0, 0, 1, 0.97])` or ignore.\n\n5. **TimesFM 2.5 required for `forecast_with_covariates()`** -- TimesFM 1.0 does NOT have this method. Install `pip install timesfm[xreg]` and use checkpoint `google\u002Ftimesfm-2.5-200m-pytorch`.\n\n6. **Future covariates must span the full horizon** -- Dynamic covariates (price, promotions, holidays) must have values for BOTH the context AND the forecast horizon. You cannot pass context-only arrays.\n\n7. **Anomaly thresholds must be defined once** -- Define `CRITICAL_Z = 3.0`, `WARNING_Z = 2.0` as module-level constants. Never hardcode `3` or `2` inline.\n\n8. **Context anomaly detection uses residuals, not raw values** -- Always detrend first (`np.polyfit` linear, or seasonal decomposition), then Z-score the residuals. Raw-value Z-scores are misleading on trending data.\n\n## Validation & Verification\n\nUse the example outputs as regression baselines. If you change forecasting logic, verify:\n\n```bash\n# Anomaly detection regression check:\npython -c \"\nimport json\nd = json.load(open('examples\u002Fanomaly-detection\u002Foutput\u002Fanomaly_detection.json'))\nctx = d['context_summary']\nassert ctx['critical'] >= 1, 'Sep 2023 must be CRITICAL'\nassert any(r['date'] == '2023-09' and r['severity'] == 'CRITICAL'\n           for r in d['context_detections']), 'Sep 2023 not found'\nprint('Anomaly detection regression: PASS')\"\n\n# Covariates regression check:\npython -c \"\nimport pandas as pd\ndf = pd.read_csv('examples\u002Fcovariates-forecasting\u002Foutput\u002Fsales_with_covariates.csv')\nassert len(df) == 108, f'Expected 108 rows, got {len(df)}'\nprices = df.groupby('store_id')['price'].mean()\nassert prices['store_A'] > prices['store_B'] > prices['store_C'], 'Store price ordering wrong'\nprint('Covariates regression: PASS')\"\n```\n\n","# TimesFM Forecasting\n\n## Overview\n\nTimesFM (Time Series Foundation Model) is a pretrained decoder-only foundation model\ndeveloped by Google Research for time-series forecasting. It works **zero-shot** — feed it\nany univariate time series and it returns point forecasts with calibrated quantile\nprediction intervals, no training required.\n\nThis skill wraps TimesFM for safe, agent-friendly local inference. It includes a\n**mandatory preflight system checker** that verifies RAM, GPU memory, and disk space\nbefore the model is ever loaded so the agent never crashes a user's machine.\n\n> **Key numbers**: TimesFM 2.5 uses 200M parameters (~800 MB on disk, ~1.5 GB in RAM on\n> CPU, ~1 GB VRAM on GPU). The archived v1\u002Fv2 500M-parameter model needs ~32 GB RAM.\n> Always run the system checker first.\n\n## When to Use This Skill\n\nUse this skill when:\n\n- Forecasting **any univariate time series** (sales, demand, sensor, vitals, price, weather)\n- You need **zero-shot forecasting** without training a custom model\n- You want **probabilistic forecasts** with calibrated prediction intervals (quantiles)\n- You have time series of **any length** (the model handles 1–16,384 context points)\n- You need to **batch-forecast** hundreds or thousands of series efficiently\n- You want a **foundation model** approach instead of hand-tuning ARIMA\u002FETS parameters\n\nDo **not** use this skill when:\n\n- You need classical statistical models with coefficient interpretation → use `statsmodels`\n- You need time series classification or clustering → use `aeon`\n- You need multivariate vector autoregression or Granger causality → use `statsmodels`\n- Your data is tabular (not temporal) → use `scikit-learn`\n\n> **Note on Anomaly Detection**: TimesFM does not have built-in anomaly detection, but you can\n> use the **quantile forecasts as prediction intervals** — values outside the 90% CI (q10–q90)\n> are statistically unusual. See the `examples\u002Fanomaly-detection\u002F` directory for a full example.\n\n## ⚠️ Mandatory Preflight: System Requirements Check\n\n**CRITICAL — ALWAYS run the system checker before loading the model for the first time.**\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\nThis script checks:\n\n1. **Available RAM** — warns if below 4 GB, blocks if below 2 GB\n2. **GPU availability** — detects CUDA\u002FMPS devices and VRAM\n3. **Disk space** — verifies room for the ~800 MB model download\n4. **Python version** — requires 3.10+\n5. **Existing installation** — checks if `timesfm` and `torch` are installed\n\n> **Note:** Model weights are **NOT stored in this repository**. TimesFM weights (~800 MB)\n> download on-demand from HuggingFace on first use and cache in `~\u002F.cache\u002Fhuggingface\u002F`.\n> The preflight checker ensures sufficient resources before any download begins.\n\n```mermaid\nflowchart TD\n    accTitle: Preflight System Check\n    accDescr: Decision flowchart showing the system requirement checks that must pass before loading TimesFM.\n\n    start[\"? Run check_system.py\"] --> ram{\"RAM ≥ 4 GB?\"}\n    ram -->|\"Yes\"| gpu{\"GPU available?\"}\n    ram -->|\"No (2-4 GB)\"| warn_ram[\"⚠️ Warning: tight RAM\u003Cbr\u002F>CPU-only, small batches\"]\n    ram -->|\"No (\u003C 2 GB)\"| block[\"? BLOCKED\u003Cbr\u002F>Insufficient memory\"]\n    warn_ram --> disk\n    gpu -->|\"CUDA \u002F MPS\"| vram{\"VRAM ≥ 2 GB?\"}\n    gpu -->|\"CPU only\"| cpu_ok[\"✅ CPU mode\u003Cbr\u002F>Slower but works\"]\n    vram -->|\"Yes\"| gpu_ok[\"✅ GPU mode\u003Cbr\u002F>Fast inference\"]\n    vram -->|\"No\"| cpu_ok\n    gpu_ok --> disk{\"Disk ≥ 2 GB free?\"}\n    cpu_ok --> disk\n    disk -->|\"Yes\"| ready[\"✅ READY\u003Cbr\u002F>Safe to load model\"]\n    disk -->|\"No\"| block_disk[\"? BLOCKED\u003Cbr\u002F>Need space for weights\"]\n\n    classDef ok fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d\n    classDef warn fill:#fef9c3,stroke:#ca8a04,stroke-width:2px,color:#713f12\n    classDef block fill:#fee2e2,stroke:#dc2626,stroke-width:2px,color:#7f1d1d\n    classDef neutral fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937\n\n    class ready,gpu_ok,cpu_ok ok\n    class warn_ram warn\n    class block,block_disk block\n    class start,ram,gpu,vram,disk neutral\n```\n\n### Hardware Requirements by Model Version\n\n| Model | Parameters | RAM (CPU) | VRAM (GPU) | Disk | Context |\n| ----- | ---------- | --------- | ---------- | ---- | ------- |\n| **TimesFM 2.5** (recommended) | 200M | ≥ 4 GB | ≥ 2 GB | ~800 MB | up to 16,384 |\n| TimesFM 2.0 (archived) | 500M | ≥ 16 GB | ≥ 8 GB | ~2 GB | up to 2,048 |\n| TimesFM 1.0 (archived) | 200M | ≥ 8 GB | ≥ 4 GB | ~800 MB | up to 2,048 |\n\n> **Recommendation**: Always use TimesFM 2.5 unless you have a specific reason to use an\n> older checkpoint. It is smaller, faster, and supports 8× longer context.\n\n## ? Installation\n\n### Step 1: Verify System (always first)\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\n### Step 2: Install TimesFM\n\n```bash\n# Using uv (recommended by this repo)\nuv pip install timesfm[torch]\n\n# Or using pip\npip install timesfm[torch]\n\n# For JAX\u002FFlax backend (faster on TPU\u002FGPU)\nuv pip install timesfm[flax]\n```\n\n### Step 3: Install PyTorch for Your Hardware\n\n```bash\n# CUDA 12.1 (NVIDIA GPU)\npip install torch>=2.0.0 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcu121\n\n# CPU only\npip install torch>=2.0.0 --index-url https:\u002F\u002Fdownload.pytorch.org\u002Fwhl\u002Fcpu\n\n# Apple Silicon (MPS)\npip install torch>=2.0.0  # MPS support is built-in\n```\n\n### Step 4: Verify Installation\n\n```python\nimport timesfm\nimport numpy as np\nprint(f\"TimesFM version: {timesfm.__version__}\")\nprint(\"Installation OK\")\n```\n\n## ? Quick Start\n\n### Minimal Example (5 Lines)\n\n```python\nimport torch, numpy as np, timesfm\n\ntorch.set_float32_matmul_precision(\"high\")\n\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\nmodel.compile(timesfm.ForecastConfig(\n    max_context=1024, max_horizon=256, normalize_inputs=True,\n    use_continuous_quantile_head=True, force_flip_invariance=True,\n    infer_is_positive=True, fix_quantile_crossing=True,\n))\n\npoint, quantiles = model.forecast(horizon=24, inputs=[\n    np.sin(np.linspace(0, 20, 200)),  # any 1-D array\n])\n# point.shape == (1, 24)        — median forecast\n# quantiles.shape == (1, 24, 10) — 10th–90th percentile bands\n```\n\n### Forecast from CSV\n\n```python\nimport pandas as pd, numpy as np\n\ndf = pd.read_csv(\"monthly_sales.csv\", parse_dates=[\"date\"], index_col=\"date\")\n\n# Convert each column to a list of arrays\ninputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]\n\npoint, quantiles = model.forecast(horizon=12, inputs=inputs)\n\n# Build a results DataFrame\nfor i, col in enumerate(df.columns):\n    last_date = df[col].dropna().index[-1]\n    future_dates = pd.date_range(last_date, periods=13, freq=\"MS\")[1:]\n    forecast_df = pd.DataFrame({\n        \"date\": future_dates,\n        \"forecast\": point[i],\n        \"lower_80\": quantiles[i, :, 2],  # 20th percentile\n        \"upper_80\": quantiles[i, :, 8],  # 80th percentile\n    })\n    print(f\"\\n--- {col} ---\")\n    print(forecast_df.to_string(index=False))\n```\n\n### Forecast with Covariates (XReg)\n\nTimesFM 2.5+ supports exogenous variables through `forecast_with_covariates()`. Requires `timesfm[xreg]`.\n\n```python\n# Requires: uv pip install timesfm[xreg]\npoint, quantiles = model.forecast_with_covariates(\n    inputs=inputs,\n    dynamic_numerical_covariates={\"price\": price_arrays},\n    dynamic_categorical_covariates={\"holiday\": holiday_arrays},\n    static_categorical_covariates={\"region\": region_labels},\n    xreg_mode=\"xreg + timesfm\",  # or \"timesfm + xreg\"\n)\n```\n\n| Covariate Type | Description | Example |\n| -------------- | ----------- | ------- |\n| `dynamic_numerical` | Time-varying numeric | price, temperature, promotion spend |\n| `dynamic_categorical` | Time-varying categorical | holiday flag, day of week |\n| `static_numerical` | Per-series numeric | store size, account age |\n| `static_categorical` | Per-series categorical | store type, region, product category |\n\n**XReg Modes:**\n- `\"xreg + timesfm\"` (default): TimesFM forecasts first, then XReg adjusts residuals\n- `\"timesfm + xreg\"`: XReg fits first, then TimesFM forecasts residuals\n\n> See `examples\u002Fcovariates-forecasting\u002F` for a complete example with synthetic retail data.\n\n### Anomaly Detection (via Quantile Intervals)\n\nTimesFM does not have built-in anomaly detection, but the **quantile forecasts naturally provide\nprediction intervals** that can detect anomalies:\n\n```python\npoint, q = model.forecast(horizon=H, inputs=[values])\n\n# 90% prediction interval\nlower_90 = q[0, :, 1]  # 10th percentile\nupper_90 = q[0, :, 9]  # 90th percentile\n\n# Detect anomalies: values outside the 90% CI\nactual = test_values  # your holdout data\nanomalies = (actual \u003C lower_90) | (actual > upper_90)\n\n# Severity levels\nis_warning = (actual \u003C q[0, :, 2]) | (actual > q[0, :, 8])  # outside 80% CI\nis_critical = anomalies  # outside 90% CI\n```\n\n| Severity | Condition | Interpretation |\n| -------- | --------- | -------------- |\n| **Normal** | Inside 80% CI | Expected behavior |\n| **Warning** | Outside 80% CI | Unusual but possible |\n| **Critical** | Outside 90% CI | Statistically rare (\u003C 10% probability) |\n\n> See `examples\u002Fanomaly-detection\u002F` for a complete example with visualization.\n\n```python\n# Requires: uv pip install timesfm[xreg]\npoint, quantiles = model.forecast_with_covariates(\n    inputs=inputs,\n    dynamic_numerical_covariates={\"temperature\": temp_arrays},\n    dynamic_categorical_covariates={\"day_of_week\": dow_arrays},\n    static_categorical_covariates={\"region\": region_labels},\n    xreg_mode=\"xreg + timesfm\",  # or \"timesfm + xreg\"\n)\n```\n\n## ? Understanding the Output\n\n### Quantile Forecast Structure\n\nTimesFM returns `(point_forecast, quantile_forecast)`:\n\n- **`point_forecast`**: shape `(batch, horizon)` — the median (0.5 quantile)\n- **`quantile_forecast`**: shape `(batch, horizon, 10)` — ten slices:\n\n| Index | Quantile | Use |\n| ----- | -------- | --- |\n| 0 | Mean | Average prediction |\n| 1 | 0.1 | Lower bound of 80% PI |\n| 2 | 0.2 | Lower bound of 60% PI |\n| 3 | 0.3 | — |\n| 4 | 0.4 | — |\n| **5** | **0.5** | **Median (= `point_forecast`)** |\n| 6 | 0.6 | — |\n| 7 | 0.7 | — |\n| 8 | 0.8 | Upper bound of 60% PI |\n| 9 | 0.9 | Upper bound of 80% PI |\n\n### Extracting Prediction Intervals\n\n```python\npoint, q = model.forecast(horizon=H, inputs=data)\n\n# 80% prediction interval (most common)\nlower_80 = q[:, :, 1]  # 10th percentile\nupper_80 = q[:, :, 9]  # 90th percentile\n\n# 60% prediction interval (tighter)\nlower_60 = q[:, :, 2]  # 20th percentile\nupper_60 = q[:, :, 8]  # 80th percentile\n\n# Median (same as point forecast)\nmedian = q[:, :, 5]\n```\n\n```mermaid\nflowchart LR\n    accTitle: Quantile Forecast Anatomy\n    accDescr: Diagram showing how the 10-element quantile vector maps to prediction intervals.\n\n    input[\"? Input Series\u003Cbr\u002F>1-D array\"] --> model[\"? TimesFM\u003Cbr\u002F>compile + forecast\"]\n    model --> point[\"? Point Forecast\u003Cbr\u002F>(batch, horizon)\"]\n    model --> quant[\"? Quantile Forecast\u003Cbr\u002F>(batch, horizon, 10)\"]\n    quant --> pi80[\"80% PI\u003Cbr\u002F>q[:,:,1] – q[:,:,9]\"]\n    quant --> pi60[\"60% PI\u003Cbr\u002F>q[:,:,2] – q[:,:,8]\"]\n    quant --> median[\"Median\u003Cbr\u002F>q[:,:,5]\"]\n\n    classDef data fill:#dbeafe,stroke:#2563eb,stroke-width:2px,color:#1e3a5f\n    classDef model fill:#f3e8ff,stroke:#9333ea,stroke-width:2px,color:#581c87\n    classDef output fill:#dcfce7,stroke:#16a34a,stroke-width:2px,color:#14532d\n\n    class input data\n    class model model\n    class point,quant,pi80,pi60,median output\n```\n\n## ? ForecastConfig Reference\n\nAll forecasting behavior is controlled by `timesfm.ForecastConfig`:\n\n```python\ntimesfm.ForecastConfig(\n    max_context=1024,                    # Max context window (truncates longer series)\n    max_horizon=256,                     # Max forecast horizon\n    normalize_inputs=True,               # Normalize inputs (RECOMMENDED for stability)\n    per_core_batch_size=32,              # Batch size per device (tune for memory)\n    use_continuous_quantile_head=True,   # Better quantile accuracy for long horizons\n    force_flip_invariance=True,          # Ensures f(-x) = -f(x) (mathematical consistency)\n    infer_is_positive=True,              # Clamp forecasts ≥ 0 when all inputs > 0\n    fix_quantile_crossing=True,          # Ensure q10 ≤ q20 ≤ ... ≤ q90\n    return_backcast=False,               # Return backcast (for covariate workflows)\n)\n```\n\n| Parameter | Default | When to Change |\n| --------- | ------- | -------------- |\n| `max_context` | 0 | Set to match your longest historical window (e.g., 512, 1024, 4096) |\n| `max_horizon` | 0 | Set to your maximum forecast length |\n| `normalize_inputs` | False | **Always set True** — prevents scale-dependent instability |\n| `per_core_batch_size` | 1 | Increase for throughput; decrease if OOM |\n| `use_continuous_quantile_head` | False | **Set True** for calibrated prediction intervals |\n| `force_flip_invariance` | True | Keep True unless profiling shows it hurts |\n| `infer_is_positive` | True | Set False for series that can be negative (temperature, returns) |\n| `fix_quantile_crossing` | False | **Set True** to guarantee monotonic quantiles |\n\n## ? Common Workflows\n\n### Workflow 1: Single Series Forecast\n\n```mermaid\nflowchart TD\n    accTitle: Single Series Forecast Workflow\n    accDescr: Step-by-step workflow for forecasting a single time series with system checking.\n\n    check[\"1. Run check_system.py\"] --> load[\"2. Load model\u003Cbr\u002F>from_pretrained()\"]\n    load --> compile[\"3. Compile with ForecastConfig\"]\n    compile --> prep[\"4. Prepare data\u003Cbr\u002F>pd.read_csv → np.array\"]\n    prep --> forecast[\"5. model.forecast()\u003Cbr\u002F>horizon=N\"]\n    forecast --> extract[\"6. Extract point + PI\"]\n    extract --> plot[\"7. Plot or export results\"]\n\n    classDef step fill:#f3f4f6,stroke:#6b7280,stroke-width:2px,color:#1f2937\n    class check,load,compile,prep,forecast,extract,plot step\n```\n\n```python\nimport torch, numpy as np, pandas as pd, timesfm\n\n# 1. System check (run once)\n# python scripts\u002Fcheck_system.py\n\n# 2-3. Load and compile\ntorch.set_float32_matmul_precision(\"high\")\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\nmodel.compile(timesfm.ForecastConfig(\n    max_context=512, max_horizon=52, normalize_inputs=True,\n    use_continuous_quantile_head=True, fix_quantile_crossing=True,\n))\n\n# 4. Prepare data\ndf = pd.read_csv(\"weekly_demand.csv\", parse_dates=[\"week\"])\nvalues = df[\"demand\"].values.astype(np.float32)\n\n# 5. Forecast\npoint, quantiles = model.forecast(horizon=52, inputs=[values])\n\n# 6. Extract prediction intervals\nforecast_df = pd.DataFrame({\n    \"forecast\": point[0],\n    \"lower_80\": quantiles[0, :, 1],\n    \"upper_80\": quantiles[0, :, 9],\n})\n\n# 7. Plot\nimport matplotlib.pyplot as plt\nfig, ax = plt.subplots(figsize=(12, 5))\nax.plot(values[-104:], label=\"Historical\")\nx_fc = range(len(values[-104:]), len(values[-104:]) + 52)\nax.plot(x_fc, forecast_df[\"forecast\"], label=\"Forecast\", color=\"tab:orange\")\nax.fill_between(x_fc, forecast_df[\"lower_80\"], forecast_df[\"upper_80\"],\n                alpha=0.2, color=\"tab:orange\", label=\"80% PI\")\nax.legend()\nax.set_title(\"52-Week Demand Forecast\")\nplt.tight_layout()\nplt.savefig(\"forecast.png\", dpi=150)\nprint(\"Saved forecast.png\")\n```\n\n### Workflow 2: Batch Forecasting (Many Series)\n\n```python\nimport pandas as pd, numpy as np\n\n# Load wide-format CSV (one column per series)\ndf = pd.read_csv(\"all_stores.csv\", parse_dates=[\"date\"], index_col=\"date\")\ninputs = [df[col].dropna().values.astype(np.float32) for col in df.columns]\n\n# Forecast all series at once (batched internally)\npoint, quantiles = model.forecast(horizon=30, inputs=inputs)\n\n# Collect results\nresults = {}\nfor i, col in enumerate(df.columns):\n    results[col] = {\n        \"forecast\": point[i].tolist(),\n        \"lower_80\": quantiles[i, :, 1].tolist(),\n        \"upper_80\": quantiles[i, :, 9].tolist(),\n    }\n\n# Export\nimport json\nwith open(\"batch_forecasts.json\", \"w\") as f:\n    json.dump(results, f, indent=2)\nprint(f\"Forecasted {len(results)} series → batch_forecasts.json\")\n```\n\n### Workflow 3: Evaluate Forecast Accuracy\n\n```python\nimport numpy as np\n\n# Hold out the last H points for evaluation\nH = 24\ntrain = values[:-H]\nactual = values[-H:]\n\npoint, quantiles = model.forecast(horizon=H, inputs=[train])\npred = point[0]\n\n# Metrics\nmae = np.mean(np.abs(actual - pred))\nrmse = np.sqrt(np.mean((actual - pred) ** 2))\nmape = np.mean(np.abs((actual - pred) \u002F actual)) * 100\n\n# Prediction interval coverage\nlower = quantiles[0, :, 1]\nupper = quantiles[0, :, 9]\ncoverage = np.mean((actual >= lower) & (actual \u003C= upper)) * 100\n\nprint(f\"MAE:  {mae:.2f}\")\nprint(f\"RMSE: {rmse:.2f}\")\nprint(f\"MAPE: {mape:.1f}%\")\nprint(f\"80% PI Coverage: {coverage:.1f}% (target: 80%)\")\n```\n\n## ⚙️ Performance Tuning\n\n### GPU Acceleration\n\n```python\nimport torch\n\n# Check GPU availability\nif torch.cuda.is_available():\n    print(f\"GPU: {torch.cuda.get_device_name(0)}\")\n    print(f\"VRAM: {torch.cuda.get_device_properties(0).total_mem \u002F 1e9:.1f} GB\")\nelif hasattr(torch.backends, \"mps\") and torch.backends.mps.is_available():\n    print(\"Apple Silicon MPS available\")\nelse:\n    print(\"CPU only — inference will be slower but still works\")\n\n# Always set this for Ampere+ GPUs (A100, RTX 3090, etc.)\ntorch.set_float32_matmul_precision(\"high\")\n```\n\n### Batch Size Tuning\n\n```python\n# Start conservative, increase until OOM\n# GPU with 8 GB VRAM:  per_core_batch_size=64\n# GPU with 16 GB VRAM: per_core_batch_size=128\n# GPU with 24 GB VRAM: per_core_batch_size=256\n# CPU with 8 GB RAM:   per_core_batch_size=8\n# CPU with 16 GB RAM:  per_core_batch_size=32\n# CPU with 32 GB RAM:  per_core_batch_size=64\n\nmodel.compile(timesfm.ForecastConfig(\n    max_context=1024,\n    max_horizon=256,\n    per_core_batch_size=32,  # \u003C-- tune this\n    normalize_inputs=True,\n    use_continuous_quantile_head=True,\n    fix_quantile_crossing=True,\n))\n```\n\n### Memory-Constrained Environments\n\n```python\nimport gc, torch\n\n# Force garbage collection before loading\ngc.collect()\nif torch.cuda.is_available():\n    torch.cuda.empty_cache()\n\n# Load model\nmodel = timesfm.TimesFM_2p5_200M_torch.from_pretrained(\n    \"google\u002Ftimesfm-2.5-200m-pytorch\"\n)\n\n# Use small batch size on low-memory machines\nmodel.compile(timesfm.ForecastConfig(\n    max_context=512,        # Reduce context if needed\n    max_horizon=128,        # Reduce horizon if needed\n    per_core_batch_size=4,  # Small batches\n    normalize_inputs=True,\n    use_continuous_quantile_head=True,\n    fix_quantile_crossing=True,\n))\n\n# Process series in chunks to avoid OOM\nCHUNK = 50\nall_results = []\nfor i in range(0, len(inputs), CHUNK):\n    chunk = inputs[i:i+CHUNK]\n    p, q = model.forecast(horizon=H, inputs=chunk)\n    all_results.append((p, q))\n    gc.collect()  # Clean up between chunks\n```\n\n## ? Integration with Other Skills\n\n### With `statsmodels`\n\nUse `statsmodels` for classical models (ARIMA, SARIMAX) as a **comparison baseline**:\n\n```python\n# TimesFM forecast\ntfm_point, tfm_q = model.forecast(horizon=H, inputs=[values])\n\n# statsmodels ARIMA forecast\nfrom statsmodels.tsa.arima.model import ARIMA\narima = ARIMA(values, order=(1,1,1)).fit()\narima_forecast = arima.forecast(steps=H)\n\n# Compare\nprint(f\"TimesFM MAE: {np.mean(np.abs(actual - tfm_point[0])):.2f}\")\nprint(f\"ARIMA MAE:   {np.mean(np.abs(actual - arima_forecast)):.2f}\")\n```\n\n### With `matplotlib` \u002F `scientific-visualization`\n\nPlot forecasts with prediction intervals as publication-quality figures.\n\n### With `exploratory-data-analysis`\n\nRun EDA on the time series before forecasting to understand trends, seasonality, and stationarity.\n\n\n\n\n\n## ? Available Scripts\n\n### `scripts\u002Fcheck_system.py`\n\n**Mandatory preflight checker.** Run before first model load.\n\n```bash\npython scripts\u002Fcheck_system.py\n```\n\nOutput example:\n```\n=== TimesFM System Requirements Check ===\n\n[RAM]       Total: 32.0 GB | Available: 24.3 GB  ✅ PASS\n[GPU]       NVIDIA RTX 4090 | VRAM: 24.0 GB      ✅ PASS\n[Disk]      Free: 142.5 GB                        ✅ PASS\n[Python]    3.12.1                                 ✅ PASS\n[timesfm]   Installed (2.5.0)                      ✅ PASS\n[torch]     Installed (2.4.1+cu121)                ✅ PASS\n\nVERDICT: ✅ System is ready for TimesFM 2.5 (GPU mode)\nRecommended: per_core_batch_size=128\n```\n\n### `scripts\u002Fforecast_csv.py`\n\nEnd-to-end CSV forecasting with automatic system check.\n\n```bash\npython scripts\u002Fforecast_csv.py input.csv \\\n    --horizon 24 \\\n    --date-col date \\\n    --value-cols sales,revenue \\\n    --output forecasts.csv\n```\n\n## ? Reference Documentation\n\nDetailed guides in `references\u002F`:\n\n| File | Contents |\n| ---- | -------- |\n| `references\u002Fsystem_requirements.md` | Hardware tiers, GPU\u002FCPU selection, memory estimation formulas |\n| `references\u002Fapi_reference.md` | Full `ForecastConfig` docs, `from_pretrained` options, output shapes |\n| `references\u002Fdata_preparation.md` | Input formats, NaN handling, CSV loading, covariate setup |\n\n## Common Pitfalls\n\n1. **Not running system check** → model load crashes on low-RAM machines. Always run `check_system.py` first.\n2. **Forgetting `model.compile()`** → `RuntimeError: Model is not compiled`. Must call `compile()` before `forecast()`.\n3. **Not setting `normalize_inputs=True`** → unstable forecasts for series with large values.\n4. **Using v1\u002Fv2 on machines with \u003C 32 GB RAM** → use TimesFM 2.5 (200M params) instead.\n5. **Not setting `fix_quantile_crossing=True`** → quantiles may not be monotonic (q10 > q50).\n6. **Huge `per_core_batch_size` on small GPU** → CUDA OOM. Start small, increase.\n7. **Passing 2-D arrays** → TimesFM expects a **list of 1-D arrays**, not a 2-D matrix.\n8. **Forgetting `torch.set_float32_matmul_precision(\"high\")`** → slower inference on Ampere+ GPUs.\n9. **Not handling NaN in output** → edge cases with very short series. Always check `np.isnan(point).any()`.\n10. **Using `infer_is_positive=True` for series that can be negative** → clamps forecasts at zero. Set False for temperature, returns, etc.\n\n## Model Versions\n\n```mermaid\ntimeline\n    accTitle: TimesFM Version History\n    accDescr: Timeline of TimesFM model releases showing parameter counts and key improvements.\n\n    section 2024\n        TimesFM 1.0 : 200M params, 2K context, JAX only\n        TimesFM 2.0 : 500M params, 2K context, PyTorch + JAX\n    section 2025\n        TimesFM 2.5 : 200M params, 16K context, quantile head, no frequency indicator\n```\n\n| Version | Params | Context | Quantile Head | Frequency Flag | Status |\n| ------- | ------ | ------- | ------------- | -------------- | ------ |\n| **2.5** | 200M | 16,384 | ✅ Continuous (30M) | ❌ Removed | **Latest** |\n| 2.0 | 500M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |\n| 1.0 | 200M | 2,048 | ✅ Fixed buckets | ✅ Required | Archived |\n\n**Hugging Face checkpoints:**\n\n- `google\u002Ftimesfm-2.5-200m-pytorch` (recommended)\n- `google\u002Ftimesfm-2.5-200m-flax`\n- `google\u002Ftimesfm-2.0-500m-pytorch` (archived)\n- `google\u002Ftimesfm-1.0-200m-pytorch` (archived)\n\n## Resources\n\n- **Paper**: [A Decoder-Only Foundation Model for Time-Series Forecasting](https:\u002F\u002Farxiv.org\u002Fabs\u002F2310.10688) (ICML 2024)\n- **Repository**: https:\u002F\u002Fgithub.com\u002Fgoogle-research\u002Ftimesfm\n- **Hugging Face**: https:\u002F\u002Fhuggingface.co\u002Fcollections\u002Fgoogle\u002Ftimesfm-release-66e4be5fdb56e960c1e482a6\n- **Google Blog**: https:\u002F\u002Fresearch.google\u002Fblog\u002Fa-decoder-only-foundation-model-for-time-series-forecasting\u002F\n- **BigQuery Integration**: https:\u002F\u002Fcloud.google.com\u002Fbigquery\u002Fdocs\u002Ftimesfm-model\n\n## Examples\n\nThree fully-working reference examples live in `examples\u002F`. Use them as ground truth for correct API usage and expected output shape.\n\n| Example | Directory | What It Demonstrates | When To Use It |\n| ------- | --------- | -------------------- | -------------- |\n| **Global Temperature Forecast** | `examples\u002Fglobal-temperature\u002F` | Basic `model.forecast()` call, CSV -> PNG -> GIF pipeline, 36-month NOAA context | Starting point; copy-paste baseline for any univariate series |\n| **Anomaly Detection** | `examples\u002Fanomaly-detection\u002F` | Two-phase detection: linear detrend + Z-score on context, quantile PI on forecast; 2-panel viz | Any task requiring outlier detection on historical + forecasted data |\n| **Covariates (XReg)** | `examples\u002Fcovariates-forecasting\u002F` | `forecast_with_covariates()` API (TimesFM 2.5), covariate decomposition, 2x2 shared-axis viz | Retail, energy, or any series with known exogenous drivers |\n\n### Running the Examples\n\n```bash\n# Global temperature (no TimesFM 2.5 needed)\ncd examples\u002Fglobal-temperature && python run_forecast.py && python visualize_forecast.py\n\n# Anomaly detection (uses TimesFM 1.0)\ncd examples\u002Fanomaly-detection && python detect_anomalies.py\n\n# Covariates (API demo -- requires TimesFM 2.5 + timesfm[xreg] for real inference)\ncd examples\u002Fcovariates-forecasting && python demo_covariates.py\n```\n\n### Expected Outputs\n\n| Example | Key output files | Acceptance criteria |\n| ------- | ---------------- | ------------------- |\n| global-temperature | `output\u002Fforecast_output.json`, `output\u002Fforecast_visualization.png` | `point_forecast` has 12 values; PNG shows context + forecast + PI bands |\n| anomaly-detection | `output\u002Fanomaly_detection.json`, `output\u002Fanomaly_detection.png` | Sep 2023 flagged CRITICAL (z >= 3.0); >= 2 forecast CRITICAL from injected anomalies |\n| covariates-forecasting | `output\u002Fsales_with_covariates.csv`, `output\u002Fcovariates_data.png` | CSV has 108 rows (3 stores x 36 weeks); stores have **distinct** price arrays |\n\n## Quality Checklist\n\nRun this checklist after every TimesFM task before declaring success:\n\n- [ ] **Output shape correct** -- `point_fc` shape is `(n_series, horizon)`, `quant_fc` is `(n_series, horizon, 10)`\n- [ ] **Quantile indices** -- index 0 = mean, 1 = q10, 2 = q20 ... 9 = q90. **NOT** 0 = q0, 1 = q10.\n- [ ] **Frequency flag** -- TimesFM 1.0\u002F2.0: pass `freq=[0]` for monthly data. TimesFM 2.5: no freq flag.\n- [ ] **Series length** -- context must be >= 32 data points (model minimum). Warn if shorter.\n- [ ] **No NaN** -- `np.isnan(point_fc).any()` should be False. Check input series for gaps first.\n- [ ] **Visualization axes** -- if multiple panels share data, use `sharex=True`. All time axes must cover the same span.\n- [ ] **Binary outputs in Git LFS** -- PNG and GIF files must be tracked via `.gitattributes` (repo root already configured).\n- [ ] **No large datasets committed** -- any real dataset > 1 MB should be downloaded to `tempfile.mkdtemp()` and annotated in code.\n- [ ] **`matplotlib.use('Agg')`** -- must appear before any pyplot import when running headless.\n- [ ] **`infer_is_positive`** -- set `False` for temperature anomalies, financial returns, or any series that can be negative.\n\n## Common Mistakes\n\nThese bugs have appeared in this skill's examples. Learn from them:\n\n1. **Quantile index off-by-one** -- The most common mistake. `quant_fc[..., 0]` is the **mean**, not q0. q10 = index 1, q90 = index 9. Always define named constants: `IDX_Q10, IDX_Q20, IDX_Q80, IDX_Q90 = 1, 2, 8, 9`.\n\n2. **Variable shadowing in comprehensions** -- If you build per-series covariate dicts inside a loop, do NOT use the loop variable as the comprehension variable. Accumulate into separate `dict[str, ndarray]` outside the loop, then assign.\n   ```python\n   # WRONG -- outer `store_id` gets shadowed:\n   covariates = {store_id: arr[store_id] for store_id in stores}  # inside outer loop over store_id\n   # CORRECT -- use a different name or accumulate beforehand:\n   prices_by_store: dict[str, np.ndarray] = {}\n   for store_id, config in stores.items():\n       prices_by_store[store_id] = compute_price(config)\n   ```\n\n3. **Wrong CSV column name** -- The global-temperature CSV uses `anomaly_c`, not `anomaly`. Always `print(df.columns)` before accessing.\n\n4. **`tight_layout()` warning with `sharex=True`** -- Harmless; suppress with `plt.tight_layout(rect=[0, 0, 1, 0.97])` or ignore.\n\n5. **TimesFM 2.5 required for `forecast_with_covariates()`** -- TimesFM 1.0 does NOT have this method. Install `pip install timesfm[xreg]` and use checkpoint `google\u002Ftimesfm-2.5-200m-pytorch`.\n\n6. **Future covariates must span the full horizon** -- Dynamic covariates (price, promotions, holidays) must have values for BOTH the context AND the forecast horizon. You cannot pass context-only arrays.\n\n7. **Anomaly thresholds must be defined once** -- Define `CRITICAL_Z = 3.0`, `WARNING_Z = 2.0` as module-level constants. Never hardcode `3` or `2` inline.\n\n8. **Context anomaly detection uses residuals, not raw values** -- Always detrend first (`np.polyfit` linear, or seasonal decomposition), then Z-score the residuals. Raw-value Z-scores are misleading on trending data.\n\n## Validation & Verification\n\nUse the example outputs as regression baselines. If you change forecasting logic, verify:\n\n```bash\n# Anomaly detection regression check:\npython -c \"\nimport json\nd = json.load(open('examples\u002Fanomaly-detection\u002Foutput\u002Fanomaly_detection.json'))\nctx = d['context_summary']\nassert ctx['critical'] >= 1, 'Sep 2023 must be CRITICAL'\nassert any(r['date'] == '2023-09' and r['severity'] == 'CRITICAL'\n           for r in d['context_detections']), 'Sep 2023 not found'\nprint('Anomaly detection regression: PASS')\"\n\n# Covariates regression check:\npython -c \"\nimport pandas as pd\ndf = pd.read_csv('examples\u002Fcovariates-forecasting\u002Foutput\u002Fsales_with_covariates.csv')\nassert len(df) == 108, f'Expected 108 rows, got {len(df)}'\nprices = df.groupby('store_id')['price'].mean()\nassert prices['store_A'] > prices['store_B'] > prices['store_C'], 'Store price ordering wrong'\nprint('Covariates regression: PASS')\"\n```\n\n",{"app":20,"name":5,"agents":51,"inputs":53,"attempts":54,"successes":54,"confidence":14,"description":7,"last_adjusted":55,"expected_state":56,"requires_approval":59},[52],"*",[],0,"2026-05-11T21:21:45+00:00",{"description":57,"verification_tool":58},"Imported skill — behavior matches source repo","none",true,"master","5f13b5d2b532c0ab6f847e3aa24d4bfe66f7d461","skills\u002Fscience\u002Ftimesfm-forecasting","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os","https:\u002F\u002Fgithub.com\u002FFlissel","https:\u002F\u002Fvibemind.space","Co-founder & CTO, VibeMind - a voice-first agentic OS for non-technical founders. Agents that do the work, not describe it.","2026-11-15 02:57:54",{"source":8,"skillName":5,"commands":69,"prompt":79,"zipAvailable":59},[70,73,76],{"tool":71,"command":72},"npx","npx skills add Flissel\u002Fvibemind-os --skill science-timesfm-forecasting",{"tool":74,"command":75},"bunx","bunx skills add Flissel\u002Fvibemind-os --skill science-timesfm-forecasting",{"tool":77,"command":78},"pnpm","pnpm dlx skills add Flissel\u002Fvibemind-os --skill science-timesfm-forecasting","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fskills\u002Fscience\u002Ftimesfm-forecasting\u002FSKILL.md",[],[82,90,98,105,133,141],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":89},"01M7DTM31MG69FRRMZF1E414G8","event-task-image-uploads","Foto aus dem Chat an eine Aufgabe der Event-App hängen.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Fevent_management\u002Fconfig\u002Fworkspace-legacy\u002Fskills\u002Fevent-task-image-uploads\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":91,"name":92,"nameZh":6,"description":93,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":46},"01M6JAA67M92TRE7GWDJDBTA9T","review","Review a change.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Frowboat\u002Fpackages\u002Fopenai-plugin-runtime\u002Ftest\u002Ffixtures\u002Fcomplete-plugin\u002Fskills\u002Freview\u002FSKILL.md",[],[92,97],"change",{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":46},"01M6JAA3DZR55G8ZY493BE9NBB","triage","Triage a change.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Frowboat\u002Fpackages\u002Fopenai-plugin-runtime\u002Ftest\u002Ffixtures\u002Fcomplete-plugin\u002Fskills\u002Fgroup\u002Ftriage\u002FSKILL.md",[],[100,97],{"skillNo":106,"name":107,"nameZh":6,"description":108,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":46},"01M6JA9XPVHENK0FQN7HBK54NV","zentrale-werkzeuge","Werkzeuge der Zentrale – nutzen bei GitHub-Fragen (Projekte updaten, Repos, Issues, PRs, Commits, CI\u002FActions-Status, README), bei Fragen zum eigenen Gitea (Sicherung\u002FSpiegel, Repos, Issues, Commits), wenn neueste Docs\u002FDoku zu einer Bibliothek oder einem Dienst geholt werden sollen, wenn ein Dashboard aus meinen Daten gebaut werden soll und wenn ich sage 'auf meinem PC suchen' oder 'such auf dem Rechner nach …'.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Fdeploy\u002Fheadless\u002Fskills\u002Fzentrale-werkzeuge\u002FSKILL.md",[],[112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132],"zentrale werkzeuge","issues","repos","grep","status","list","docs","URL","file","add","prs","ci","mkdir","actions","README","commits","github","gitea","dashboard","fetch","todo",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":46},"01M6JA9SQPX187CVC148SQT1SP","wissen-suchen","Bedeutungssuche im Rowboat-Wissen – IMMER zuerst nutzen, wenn nach Kunden, Kontakten, Themen, Interessen, Notizen oder 'was wissen wir über …' gefragt wird, besonders wenn die genauen Wörter unklar sind.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Frowboat\u002Fdeploy\u002Fheadless\u002Fskills\u002Fwissen-suchen\u002FSKILL.md",[],[140],"wissen suchen",{"skillNo":142,"name":143,"nameZh":6,"description":144,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":145,"categories":146,"keywords":147,"publishedAt":46},"01M6JA9P6GNFPE21101SDZS3BT","reel-aus-material","Reel aus vorhandenen Laura-Videos: passende Stellen im Transkript finden; spricht dort eine Person, bleibt ihr Originalton (mit Untertiteln aus dem Transkript), sonst trägt ein eingesprochener Satz den Clip. Bei Aufträgen der Art 'material'.","https:\u002F\u002Fgithub.com\u002FFlissel\u002Fvibemind-os\u002Fblob\u002Fmaster\u002Fspaces\u002Fmarketing\u002Fvideo_claw\u002Fskills\u002Freel-aus-material\u002FSKILL.md",[],[148,149,150,151,152,153,154],"reel","reel aus material","material","clip","Art","videos","person"]