Training DeepAR

In this section, we will fit DeepAR to the weekly sales. Let's start by preparing training and test datasets in JSON format.

Let's have a look at the following code, which demonstrates the creation of json lines:

import deepar as datrain_key      = 'deepar_sales_training.json'test_key       = 'deepar_sales_test.json'#Prediction and context length for training the DeepAR modelprediction_length = 9salesfn = 'data/store20_sales.csv'salesdf = da.retailsales.prepareSalesData(salesfn)testSet = da.retailsales.getTestSales(salesdf, test_key)trainingSet = da.retailsales.getTrainSales(salesdf, train_key, prediction_length)

In the preceding code block, we have created JSON lines for training and testing the datasets:

  • The prepareSalesData() function ...

Get Hands-On Artificial Intelligence on Amazon Web Services now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.