> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tabsutra.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Forecasting

> Forecast one or many time series, with the inputs you know in advance.

A forecast predicts the future values of a series measured at regular steps: daily sales of an item in a store, hourly electricity load, weekly calls to a service desk. tabSutra forecasts one series or many thousands in one request. It does not need a model per series, and it does not need to be trained on your history first.

## The data

Send the history as a table with one row per series and step.

```csv sales.csv theme={null}
store,sku,date,units,price,on_promotion,store_type
S12,4471,2026-11-01,14,99.0,0,large
S12,4471,2026-11-02,11,99.0,0,large
S12,4471,2026-11-03,23,89.0,1,large
S12,5520,2026-11-01,3,450.0,0,large
...
```

* `series_column` names the column, or the columns, that identify a series. Here a series is one item in one store, so it is `["store", "sku"]`. Leave it out when the table holds one series.
* `time_column` holds the date or the time of each step.
* `target` is the column to forecast.

Every other column is read as an input. How it is read depends on whether you also know its future values.

| Kind of column | Example | How to send it |
| - | - | - |
| Known in advance | price, planned promotion, holiday, scheduled maintenance | In the history, and again in `future_rows` for the steps to forecast |
| Known only in the past | footfall, temperature measured, competitor price observed | In the history only |
| Fixed for the series | store type, item category, region | In the history; the value is the same on every row of the series |

## Forecast

```python theme={null}
history = pd.read_csv("sales.csv")
future = pd.read_csv("sales_plan.csv")      # store, sku, date, price, on_promotion for the next 28 days

forecast = requests.post(f"{API}/v1/forecast", headers=HEADERS, json={
    "rows": records(history),
    "future_rows": records(future),
    "series_column": ["store", "sku"],
    "time_column": "date",
    "target": "units",
    "horizon": 28,
    "target_range": [0, None],
    "quantiles": [0.1, 0.5, 0.9],
}).json()
```

The settings are:

| Setting | Default | Meaning |
| - | - | - |
| `horizon` | required | The number of steps to forecast. |
| `frequency` | inferred | The step of the series: `H` (hour), `D` (day), `W` (week), `M` (month), `Q` (quarter), `Y` (year), or a multiple such as `15min`. |
| `future_rows` | none | The inputs known in advance, one row per series and future step. |
| `target_range` | none | A range the forecasts are clipped to. Use `[0, null]` for sales and other amounts that cannot be negative. |
| `as_of` | the last step | Forecast from an earlier date. The history after it is not read. |
| `outputs`, `quantiles`, `coverage` | mean, median, three quantiles, 80% interval | What each prediction contains. See [Outputs](https://docs.tabsutra.com/concepts/outputs.md). |
| `explain` | false | Add the contribution of each input to each step. See [Explanations](https://docs.tabsutra.com/concepts/explainability.md). |

The answer has one prediction per series and future step.

```json theme={null}
{"series": "S12/4471", "time": "2026-12-01", "step": 1,
 "mean": 16.2, "median": 15.0, "quantiles": {"0.1": 7.0, "0.5": 15.0, "0.9": 27.0}}
```

## Many series together

The series in one request are read together. A series with a short history can borrow from the others, so a new item or a new store gets a sensible forecast from its first weeks. For the same reason, send related series in the same request, such as all the items of one store, or one item across stores.

## Intermittent and seasonal series

Many business series are mostly zeros with an occasional sale, such as spare parts or slow-moving items. Others have strong weekly or yearly patterns. The model handles both without a choice of method on your side. For intermittent series, read the quantiles rather than the mean: the median of a slow item is often zero, and the upper quantiles tell you how much stock covers a good week.

## Adding up forecasts

The mean of a total is the sum of the means. So to forecast a store's total, or a week from its days, add the means. Do not add quantiles: the 90% quantile of a week is not the sum of the 90% quantiles of its days. If you need the quantiles of a total, forecast the total as a series of its own.

## Evaluate

`/v1/evaluate-forecast` holds out the last `horizon` steps of every series, forecasts them from the history before, and scores the result.

```python theme={null}
result = requests.post(f"{API}/v1/evaluate-forecast", headers=HEADERS, json={
    "rows": records(history), "series_column": ["store", "sku"], "time_column": "date",
    "target": "units", "horizon": 28, "windows": 3,
}).json()
print(result["ours"], result["baseline"])
```

With `windows` set to more than one, the test is repeated from several start dates, each one `horizon` steps earlier, and the scores are averaged.

The scores are:

| Score | Meaning |
| - | - |
| `mase` | The mean absolute error of the median, divided by the error of a seasonal naive forecast on the history. Below 1 is better than the naive forecast. |
| `wql` | The weighted quantile loss over the predicted distribution. It scores the whole distribution, not only its middle. Lower is better. |
| `mae`, `rmse` | The errors of the median and of the mean, in the units of the target. |
| `inside_80pct_interval` | The share of held-out values inside the 80% interval. It should be close to 0.8. |

The baseline is the seasonal naive forecast: the value of the same step one season earlier, such as the same weekday last week.

## Files

`/v1/forecast-file` takes the history as a CSV or Parquet file in `history`, and the inputs known in advance in `future`. It returns JSON, CSV or Parquet, as you choose with `format`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.