So in this lecture, we finally arrived at the last step in the process, which is to actually generate
our forecast and look at the results at this point.
We've just trained our predictor, which took about half an hour.
If you turn on auto amandola, hyper parameter optimization, it may have taken a few hours.
So, as always, the thing we're about to create needs a name.
So we'll call it deep error plus forecast.
The next step is to call the creative forecast function passing in the forecast name, as well as the
hÉireann for the predictor.
This creates another area which will call the forecast there at.
Again, we've just launched the job, so we need to wait until it's complete.
In the next block, we call the described forecast function passing in the air and for the forecast,
once the status becomes active, then your forecast is ready.
Note that when I ran this, it took approximately 10 minutes.
So definitely much longer than it would take calling model to predict on your Tenzer flow model.
So where is the forecast we've just created?
Well, you'll recall that at the beginning of this script, we created two clients with boats of three.
One was the forecast client and one was the forecast query client.
Once we've generated our forecast, we can query it using the forecast query client.
So the next thing we're going to do is call the query forecast function using the forecast query client,
as mentioned previously, you're strongly encouraged to open up the Boto three documentation so you
can see all these functions and arguments for yourself.
I'm showing you what I've used, but be aware that there are still more options.
So when we call this function, we're going to pass in the forecast.
They are in which we just got it.
And the item ID we want to query, since we only have one item ID, this must be spy.
The next step is to just look at the response to see what we got, if you inspect this yourself, you'll
see that there are really three main arrays you can see there.
We have a nested dictionary with the key forecast than the key predictions and the keep 10.
This points to a list which contains dictionaries.
And each of these dictionaries is essentially a data point in our forecast.
The first element is the timestamp, and the second element is the value, which really is the predicted
value at that time stamp.
So what does it mean?
As you recall, our forecast model generates three predictions, one for the 10 percent percentile,
one for the 50 percent percentile and one for the 90 percent percentile.
So if we scroll down, we can see the keys for P 50 and P 90 as well with their corresponding list of
values.
Our next goal is to put all this data into a data frame, so in order to do that, we're going to pass
this data into a list of tuples.
Each tuple will have a timestamp followed by each of the three percentiles.
And this next function called Adewusi forecast, we're going to accept three dictionaries, D 10, D
50, Endi 90.
The basic idea is we're going to live through each of the lists we saw earlier in corresponding order.
So each of these dictionaries we pass in should correspond to the same time stamp.
You might want to write a function to verify that this is the case.
Inside the function, we first grab the timestamp key and cast this to a pan as timestamp, as you recall,
the value returned by Adewusi is a string, but the panda's time stamp constructor can pass this automatically.
Next, we obtain the three values, which I've just called eval one, eval two and three.
Finally, this function returns each of the four items we just described.
Next, to make things a little clearer, we're going to index the forecast response to grab the and
P 50 and P 90 list.
After that, we're going to use the zip function to loop through each list in parallel.
So we visit each of the corresponding items at the same time.
We then pass each of these items into the function we just created.
We call the result of that past.
Next, we create a new data frame out of our list of tuples, giving it the column names Timestamp 10,
P fifty and P ninety.
Next, we call the set index function on the time stamp column so that it becomes the index.
The next step is to plot our forecast, along with the original Time series, to see how accurate it
is.
Note that in practice you're really going to predict the future.
So this won't be possible.
This lecture is more about seeing how good or bad eight of us forecast is.
So we're going to create a new data frame which just indexes our old D.F. at the close column.
We'll call this new data frame true.
D.F. will then rename this single column to True.
Next, we join Trudeau with the forecast D.F. we just created using an outer join, this will make it
so that any dates not included in either data frame will just be filled with any ads.
This is fine since they don't show up on the plot.
Finally, we call the plot function and look at the results.
As you can see, it doesn't look too bad, although the interesting part is perhaps a bit too small.
In the next line, I've selected only the last one hundred data points and run the plot function again,
this time we can see that in fact the forecast really isn't that bad.
It seems to predict the trend fairly well.
Interestingly, it predicts that the price will fall and then go back up, which is what happens, although
not exactly at the same time.
Furthermore, we can see that the true value goes above the 90 percent percentile for most of the forecast.
However, it's important to note that the market was performing unexpectedly well during this time after
the crash of twenty twenty.
So as an exercise, you may want to implement a quantitative evaluation metric and compare the results
of this forecast with something else you implemented in this course.