Moving-average model example
Moving average models use the errors of previous predictions to make future predictions. More specifically, the user-specified lag determines how many previous predictions and errors it takes into account during computation.
Use the following functions when training and predicting with moving-average models. Note that these functions require datasets with consistent timesteps.
-
MOVING_AVERAGE
: trains a moving-average model -
PREDICT_MOVING_AVERAGE
: applies the model to a dataset to make predictions
To normalize datasets with inconsistent timesteps, see Gap filling and interpolation (GFI).
Example
-
Load the datasets from the Machine-Learning-Examples repository.
This example uses the daily-min-temperatures dataset, which contains data on the daily minimum temperature in Melbourne, Australia from 1981 through 1990:
-
Use
MOVING_AVERAGE
to create the moving-average modelMA_temperature
from thetemp_data
dataset. In this case, the model is trained with a lag ofp
=3, taking the error of 3 previous predictions into account for each estimation:You can view a summary of the model with
GET_MODEL_SUMMARY
: -
Use
PREDICT_MOVING_AVERAGE
to predict future temperatures. The following querystart
s the prediction at the end of the dataset and returns 10 predictions.