Forecast with a prediction function
A prediction function forecasts a number for one series at a time, such as next week's orders in one region, from the events your playbook already records. This guide sets one up in a playbook you already have. Each step says what to ask your agent and what you should see.
A prediction function calls no language model, and needs nothing set up first. The runtime's forecaster answers each question from the series' own history, as soon as that history is long enough. Prediction function format holds every field and rule.
Before you start
- Your agent is connected to Auto with permission to change your playbook (
playbook:write). The quick start sets this up. - You know the number to forecast and how many periods ahead you will ask. A period is a day, a week, a month, a quarter or a year.
- The playbook records an event for each thing you count, such as
order.placed, with a time and its series, such as the region. Your systems publish them, or its workflows emit them.
1. Choose the events
The function forecasts from the playbook's history. New events join its data as the playbook records them, so each question answers from the latest periods.
Ask your agent:
I want to forecast <the number, such as orders> for each <series, such as
region>, <how many> <periods> ahead, in my "<playbook name>" playbook. Does
its history record an event for each <thing counted>, with its time and its
<series>? Which events, and how many periods do they cover?You should see the agent name the events it found, where each holds its time and its series, and how far back they go. The dataset has the fields that read them.
2. Save the function
Ask:
Draft a prediction function named "<function name>" in my "<playbook name>"
playbook. It forecasts <the number> per <period> for each <series>, <how many>
periods ahead, from <the events>. Give it a page that shows each forecast. Show
me the document and explain each setting before saving it.You should see a document of YAML front matter between --- lines and nothing after it. Check that the target, the period and the horizons are the ones you meant, and that its page shows what you asked for.
What the document settles
predicts: thetarget, itsperiod, itshorizons(how many periods ahead a question may ask) and itsunit. Name aseasonwhen the numbers repeat, such as 52 for weeks over a year or 7 for days over a week. For a total to the end of a period, nameaccumulatesin place ofhorizons.coverageis how often each range is meant to hold the truth, 0.8 unless you name another.data: the events, where each holds its time and its series, how the target is read and aggregated over a period, and thewindowof periods a question reads. A number that each period has once, such as a week's revenue, is aggregated aslast, so that a week recorded again replaces its value rather than adding to it.page: what you see of each forecast, the likely value ahead with its range. A function asked of several series, such as one for each region, has norunsof the forecasts against what happened, since an answer does not name its series; Its page says when a page can have one.
A function document shows a full example, and Fields lists every field.
Approve it, and the agent saves it with create_definition. A save that breaks a rule is refused at its line, and nothing is saved.
The playbook then builds the function's dataset from its history: one row for each series and period. get_definition shows its phase under standing.dataset: waiting until the build starts, rebuilding while the build reads the history, and live once the history is read.
3. Ask for a forecast
Ask:
Ask the "<function name>" function in my "<playbook name>" playbook for
<series>'s <number> <how many> <periods> ahead.The agent runs the function with a question, such as { "series": "north", "horizon": 1 }, and the run returns the forecast at once. Without horizon, it forecasts every horizon the function names. The forecast is a series, which the function's page draws where Auto Studio shows the run, with its lines named in your words, as The lines on a page shows. Read it like this:
originis the last observed period, the one before the period you asked in.- The
observedline holds the last periods of the data up to the origin: twice the longest horizon, at most the window, unless the document'spredicts.historysays how many. - The
predictedline holds a point for each period forecast. Itsvalueis the likely value. - Its
lowandhighare the range meant to hold the true value eight times in ten, or as often as the document'scoveragesays. - The run's record names the
methodthe forecaster used, thecoverage, and inhistorythe periods it forecast from and the earlier points it checked itself at.
A function that predicts a total to the end of a period takes no horizon; A question has both kinds. A workflow asks the same question in a task. In a workflow shows how, including what to do while the history is still too short.
Keep it current
Nothing needs to be done: every question answers from the dataset as it stands when the question is asked. To change what the function forecasts from, update its document. An edit to the events, the target or the period starts a new dataset from the history; a wider window or other horizons do not.
If something goes wrong
- A question is refused
history_too_short. The series' history is too short for the forecaster to check its own forecasts on. The refusal names the periods the series has and the first period from which the same question answers, so ask again from then. - A question is refused
dataset_not_ready. The dataset is still being built from the playbook's history, so ask again onceget_definitionshows itlive. Withbecause: stalled, it stopped at an event its data test could not take;get_definitionnames the event, and a corrected data part starts a dataset of its own. - A question is refused at
/input/series. The dataset holds no row of that series in its window. Check the series' name, as the events spell it. - A forecast leaves out a run that just ended. A question reads only the periods before the one it is asked in.
- A run dated by when it ran (
time: event) falls in the current period, so it counts once that period has passed. - A run about a period that has ended, with a date of that period in its output, counts in any question started after the run ended, as A run that ended a moment ago says. So a workflow that records the period asks in the next step, with no wait or retry.
- A run still going when the question starts is not counted. Ask once it has ended.
- A run dated by when it ran (
How a run ends lists every refusal.
Next
- Prediction function format covers totals to the end of a period, the forecaster's methods and its bounds.
- Run a workflow on a schedule or event asks for a forecast on a schedule.