So in this lecture, we are going to continue our script to forecast stocks using Amazon forecast and
industrial strength forecasting solution.
So far we've downloaded our data, converted it into the correct format and uploaded that data to us.
Three, we've imported our data into Adewusi forecast by creating a data set group and data sets for
that data set group.
We've added our files from S3 to those data sets.
The next step is the fun part where we actually get to build our predictor.
You learn terminology, you can think of this like calling model does fit, although as you'll soon
see this actually does quite a bit more.
So we start by defining our algorithm and you can get these from the AWADI documentation, so don't
worry about having to memorize this.
Basically, Amazon forecast supports six different algorithms.
We'll be using an algorithm called DPR Plus, which I've chosen because I think that's what most people
taking this course would be curious about.
So what is DPR plus?
Essentially, it's an auto regressive RNA that predicts a scalar.
However, it's able to learn from a time series of multiple input features, which is exactly what we
have.
There's another algorithm called CNN QR.
So you might be interested in that if you want to try other deep learning techniques.
Interestingly, HWC forecast also lets you use profit, which was invented by Facebook, for which we
already have a Python library.
There's an algorithm called NPT's, which stands for non Parametric Time series.
This looks like it was invented by Amazon.
So there's not a lot of literature about how it works.
And finally, we have classic algorithms like Arima and exponential smoothing, which is called ETS
in the docs, note that other algorithms like Arima and ETS do not support related data sets.
So if you want to use those, then you can't have any related time series.
However, you might also want to consider whether there's any benefit of using a service like this if
all you want to do is Arima.
So overall, HWC forecast lets you choose from six different algorithms out of these.
I thought DPR plus would be the most interesting.
So that's the one we'll focus on.
So the next step is to create our predictor by calling the create predictive function.
You'll notice this takes in quite a few arguments.
First, we pass in the predictable name as well as the algorithm are in.
Next, we have the forecast horizon, which tells us how far into the future that we would like to forecast.
Next, we have a flag to choose whether or not to use.
Automatable in this case, auto will automatically select which algorithm to use.
However, since we already chose DPR plus this is not necessary.
As an exercise, you might want to try setting this to true to see if Amazon forecast to find that some
other algorithm works better.
The next option is perform HPO.
This will automatically perform hyper parameter optimization, which everyone in machine learning hates
to do.
I'm going to set this to false, but I encourage you to try this out for yourself to see how well it
works.
Do note that you do have to pay for this.
So keep in mind that this will cost both time and money.
In my experience, training with HBO on took about four hours, whereas it only took about one hour
with this setting off.
However, that was with a different data set.
So keep that in mind.
Also, recall that wall clock time is not equal to compute hours in Amazon, since Amazon runs its training
in parallel.
So if Amazon tries 100 different hyper parameter settings, you have to pay for all of them.
The next option, which I've come into now, is for choosing the forecast type.
You'll see this show up later in our forecast, but basically they represent the kind of prediction
we want to make.
By default, we get zero point one zero point five and zero point nine.
So what does this mean?
Essentially, these are quintiles or percentiles.
So zero point one means the true value is expected to be lower than the 10 percent line, 10 percent
of the time, zero point nine means the true value is expected to be lower than the 90 percent line
90 percent of the time.
This means that zero point five is the median prediction.
Also note that by default, the mean is not returned, which is what people usually expect when performing
a prediction.
So if you want the mean, you can add this to the list of return types as shown.
Lastly, we pass in our data set group Aaren, so our predictor knows where the training data can be
found and also the data set frequency.
As expected, creating the predictor launches a job for which we can check the job status, so the next
step is to grab the R.M. for our predictor.
Next, we call the function described predictor passing in the predictor, and again, you just keep
running this until it's as active as you can see.
The last time I ran this, it took less than 30 minutes.
OK, so next, we can check how accurate our model is by calling the function to get accuracy metrics.
So this will give us a big dictionary telling us various metrics about how our model performs.
As you can see, this gives us metrics like the root mean squared error, weighted, absolute percentage
error and so forth.
Note that this is on the test set, which is chosen to be the last bit of the data set that we passed
in.
OK, so to summarize this lecture, here's what we've done so far, we've learned how to take our data
and create a predictor which effectively fits a model to the data we've provided.
We've enumerated all the possible models that can be used in Adewusi forecasts.
And I think we've chosen the most interesting one DPB.
Plus, we've seen the possibility of several nice options, such as Auto Amelle and hyper parameter
optimization, which I encourage you to try it on your own.
If you're serious about training the best model possible.
In the next few lectures, we'll look at how to create a forecast from the model we've just trained
and we'll compare how close it is to the actual future prices that we've tried to predict.