POST/v1/series/forecast
Forecasts every series in the request horizon steps ahead, with nine quantiles at every step. This forecasts monthly airline
passengers: the Python and CLI tabs send the whole history and ask for two years; the cURL tab writes the last twelve
months into the request by hand and asks for two months:
import pandas as pdfrom yhatlabs import Client
url = "https://raw.githubusercontent.com/jbrownlee/Datasets/master/"df = pd.read_csv(url + "airline-passengers.csv") # columns: Month, Passengers
yh = Client()fc = yh.forecast(df, h=24, time_col="Month", target_col="Passengers", level=[80])print(fc.df.head(3).round(1))Output
| unique_id | Month | q10 | median | q90 |
|---|---|---|---|---|
| series_0 | 1961-01-01 | 430.5 | 448.5 | 468.0 |
| series_0 | 1961-02-01 | 408.9 | 430.9 | 452.0 |
| series_0 | 1961-03-01 | 449.0 | 486.7 | 508.2 |
curl -sO https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csvyhatlabs forecast airline-passengers.csv --h 24 \ --time-col Month --target-col Passengers --level 80 -o forecast.csvhead -4 forecast.csvunique_id,Month,q10,median,q90series_0,1961-01-01,430.53720868618353,448.541455316843,467.97666760754703series_0,1961-02-01,408.9291654372314,430.8968252966604,451.962356383921series_0,1961-03-01,449.0440194902994,486.74538766574983,508.24449670833036curl -s https://api.yhatlabs.com/v1/series/forecast \ -H "Authorization: Bearer $YHAT_API_KEY" \ -H "Content-Type: application/json" \ -d '{"freq": "MS", "horizon": 2, "series": [{"id": "passengers", "values": [417, 391, 419, 461, 472, 535, 622, 606, 508, 461, 390, 432]}]}'{"id":"3a90dd3d-e737-465e-b1f9-ca3c8941d464","model":"chakra-ts","horizon":2,"quantile_levels":[0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9],"forecasts":[{"id":"passengers","quantiles":[[383.0753173828125,402.9498291015625,413.9801025390625,422.4678039550781,434.37628173828125,446.0346374511719,460.8013610839844,478.62322998046875,502.9939880371094],[364.9206237792969,390.9168395996094,410.5889892578125,423.1913757324219,436.617431640625,454.6253662109375,474.06512451171875,497.9351806640625,532.4006958007812]]}],"usage":{"series":1}}Parameters: Client.forecast
The cURL tab is the raw request; the other tabs build it from a table for you.
Request
Section titled “Request”| Field | Type | Required / default | Description |
|---|---|---|---|
model |
string | "chakra-ts" |
The model, as GET /v1/models lists it. |
series |
array of Series | required | 1 to 256 series; 8,000,000 points in total, counting covariates. (at most 256) |
horizon |
integer | required | Steps to forecast, at freq. (min 1, max 2048) |
freq |
string | "h" |
A pandas frequency alias: 15min, h, D, 2D, W-SUN, MS, QS-OCT, YE-DEC. |
season |
integer | optional | The seasonal period in steps, to fix it instead of inferring it from freq. (min 1) |
quantile_levels |
array of number | optional | Any levels in (0, 1); default the nine deciles. (at most 32) |
samples |
integer | optional | Sample paths per series over the horizon. (min 1, max 1000) |
seed |
integer | optional | Seed for the sample paths. |
store |
boolean | true |
false keeps this call out of your Logs (we still keep a copy to look into errors; never used for training). |
history |
boolean | false |
Also return the model’s forecasts of the windows just before the forecast. |
preset |
fast, pro |
"fast" |
pro: slower, slightly sharper (models that have presets). |
tune |
string | optional | Forecast with a tune (POST /v1/series/tunes): the tuned model when it beat the model as it is on your latest window, else the model as it is. The reply’s tune says which. |
Each series:
| Field | Type | Required / default | Description |
|---|---|---|---|
id |
string | required | Unique within the request. (max length 256) |
values |
array of numbers or null | optional | Oldest first, equally spaced at freq; null marks a missing value. |
targets |
object | optional | Instead of values: several targets of equal length. |
past_covariates |
object of arrays | optional | Each as long as the history. |
known_covariates |
object of arrays | optional | Each as long as the history plus horizon. |
Covariates may be numbers, short text categories or null. A request may carry 8,000,000 points in total, counting covariates.
Response
Section titled “Response”| Field | Type | Description |
|---|---|---|
id |
string | The request id (also the X-Request-Id header). |
model |
string | |
horizon |
integer | |
quantile_levels |
array of number | The levels of every quantiles row, in order. |
forecasts |
array of Forecast | One per series, in request order. |
usage |
object | Quota units used: one per target column of each series. |
Each entry of forecasts:
| Field | Type | Description |
|---|---|---|
id |
string | The series’ id from the request. |
quantiles |
array of array of number | One row per step, one value per quantile level ([horizon][levels]). |
targets |
object | Several targets: {column: quantiles}, instead of quantiles. |
samples |
array of array of number | With samples=N: N paths over the horizon ([samples][horizon]). |
target_samples |
object | Several targets: {column: samples}. |
history |
array of Window | With history: the model’s forecasts of the windows just before the forecast, oldest first. |
target_history |
object | Several targets: {column: history}. |
Levels beyond the deciles (quantile_levels such as 0.025 or 0.99), samples and history are listed in the capabilities
of GET /v1/limits.

