Time Series and Forecasting

Build a trailing-mean forecast

BOTIE

Form the lag rows while preserving chronological order and excluding each target.
Ready to test
0 passed · 0 failed · 2 not run

An empty floor. Start with the information your machine needs.

Received result

Your answer will arrive here.

Examples, experiments and workspace controls
Live values

Connect a tool's inputs to see what it produces. You can try a branch before connecting it to Result.

Try your own inputs

Use a copy of the example to try your own data. Keep the problem's assumptions in mind, and predict the effect of a change before checking the output. You can also add another branch to compare two ways of doing the calculation.

Start at an output arrow, then click or drag to an input. Drag empty space to pan. Delete removes a selection. Ctrl/Cmd+Z undoes a change.
Context for this challenge

Form the lag rows while preserving chronological order and excluding each target.

Botie wants one prediction for each day that has enough preceding readings. The supplied lag count defines the history window.

Inspect the component calculation
Build earlier-value windows(
  Ordered history: Demand in chronological order
  Number of lags: Number of preceding readings
)
Examples and results
Demand in chronological order
  1. 04
  2. 16
  3. 25
  4. 39
Number of preceding readings
2
Required result
46
65
Demand in chronological order
  1. 03
  2. 16
  3. 29
  4. 38
  5. 410
Number of preceding readings
3
Required result
369
698
Try a fresh construction

This clears this draft, including its undo history. Earlier successful attempts stay recorded. Build again without opening hints to record an independent attempt.

Stuck? Inspect a worked construction

The tools below form one possible solution. You can assemble it, follow its signals, and undo that change to return to your own construction.

Assumptions and test precision

Inputs must be evenly spaced and already audited for availability. This tool does not fill missing dates. Numerical tests allow a difference of 0.001. Lists and structures must also have the right shape.

Your last tested pieces can start the full construction. An existing draft there keeps its own pieces.

Use only the days already observed

This check uses the pieces from “Keep each target outside its history row”.

BOTIE

Botie records five days of demand, ending in a sharp increase. Form each available three-day history window and predict its following day with the window mean. Return the predictions in chronological order; do not include the target day in its own window.
Demand in chronological order
  1. 010
  2. 110
  3. 210
  4. 340
  5. 4100
Number of preceding readings
3

Use a number, text, or an array matching the requested result. For a matrix, put each row in brackets. Saving your prediction runs your current construction on these inputs and checks the earlier examples too.

Build a construction in the workspace above first. This case will test those pieces.

Why would a missing calendar day make a row offset different from a one-day lag?

Lag indices represent elapsed time only when spacing and availability have been checked.

Inputs must be evenly spaced and already audited for availability. This tool does not fill missing dates.

Work through the Python challenges →
Continue the courseSeparating Repetition From Change →