Skip to content

Commit 89b417b

Browse files
Merge pull request #217265 from EricWrightAtWork/add-rolling-forecast-text
Add rolling forecast description to the Auto train timeseries page
2 parents ef71bf0 + 61c1c58 commit 89b417b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

articles/machine-learning/how-to-auto-train-forecast.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,27 @@ best_run, fitted_model = local_run.get_output()
294294

295295
## Forecasting with best model
296296

297-
Use the best model iteration to forecast values for data that wasn't used to train the model.
297+
Use the best model iteration to forecast values for data that wasn't used to train the model.
298+
299+
### Evaluating model accuracy with a rolling forecast
300+
301+
Before you put a model into production, you should evaluate its accuracy on a test set held out from the training data. A best practice procedure is a so-called rolling evaluation which rolls the trained forecaster forward in time over the test set, averaging error metrics over several prediction windows to obtain statistically robust estimates for some set of chosen metrics. Ideally, the test set for the evaluation is long relative to the model's forecast horizon. Estimates of forecasting error may otherwise be statistically noisy and, therefore, less reliable.
302+
303+
For example, suppose you train a model on daily sales to predict demand up to two weeks (14 days) into the future. If there is sufficient historic data available, you might reserve the final several months to even a year of the data for the test set. The rolling evaluation begins by generating a 14-day-ahead forecast for the first two weeks of the test set. Then, the forecaster is advanced by some number of days into the test set and you generate another 14-day-ahead forecast from the new position. The process continues until you get to the end of the test set.
304+
305+
To do a rolling evaluation, you call the `rolling_forecast` method of the `fitted_model`, then compute desired metrics on the result. For example, assume you have test set features in a pandas DataFrame called `test_features_df` and the test set actual values of the target in a numpy array called `test_target`. A rolling evaluation using the mean squared error is shown in the following code sample:
306+
307+
```python
308+
from sklearn.metrics import mean_squared_error
309+
rolling_forecast_df = fitted_model.rolling_forecast(
310+
test_features_df, test_target, step=1)
311+
mse = mean_squared_error(
312+
rolling_forecast_df[fitted_model.actual_column_name], rolling_forecast_df[fitted_model.forecast_column_name])
313+
```
314+
315+
In the above sample, the step size for the rolling forecast is set to 1 which means that the forecaster is advanced 1 period, or 1 day in our demand prediction example, at each iteration. The total number of forecasts returned by `rolling_forecast` thus depends on the length of the test set and this step size. For more details and examples see the [rolling_forecast() documentation](/python/api/azureml-training-tabular/azureml.training.tabular.models.forecasting_pipeline_wrapper_base.forecastingpipelinewrapperbase#azureml-training-tabular-models-forecasting-pipeline-wrapper-base-forecastingpipelinewrapperbase-rolling-forecast) and the [Forecasting away from training data notebook](https://github.com/Azure/azureml-examples/blob/main/v1/python-sdk/tutorials/automl-with-azureml/forecasting-forecast-function/auto-ml-forecasting-function.ipynb).
316+
317+
### Prediction into the future
298318

299319
The [forecast_quantiles()](/python/api/azureml-train-automl-client/azureml.train.automl.model_proxy.modelproxy#forecast-quantiles-x-values--typing-any--y-values--typing-union-typing-any--nonetype----none--forecast-destination--typing-union-typing-any--nonetype----none--ignore-data-errors--bool---false-----azureml-data-abstract-dataset-abstractdataset) function allows specifications of when predictions should start, unlike the `predict()` method, which is typically used for classification and regression tasks. The forecast_quantiles() method by default generates a point forecast or a mean/median forecast which doesn't have a cone of uncertainty around it. Learn more in the [Forecasting away from training data notebook](https://github.com/Azure/azureml-examples/blob/main/v1/python-sdk/tutorials/automl-with-azureml/forecasting-forecast-function/auto-ml-forecasting-function.ipynb).
300320

0 commit comments

Comments
 (0)