1
00:00:11,160 --> 00:00:16,320
So in this lecture, we finally arrived at the last step in the process, which is to actually generate

2
00:00:16,320 --> 00:00:19,450
our forecast and look at the results at this point.

3
00:00:19,470 --> 00:00:22,250
We've just trained our predictor, which took about half an hour.

4
00:00:22,680 --> 00:00:27,670
If you turn on auto amandola, hyper parameter optimization, it may have taken a few hours.

5
00:00:28,260 --> 00:00:31,170
So, as always, the thing we're about to create needs a name.

6
00:00:31,380 --> 00:00:34,170
So we'll call it deep error plus forecast.

7
00:00:37,430 --> 00:00:42,770
The next step is to call the creative forecast function passing in the forecast name, as well as the

8
00:00:42,770 --> 00:00:44,070
hÉireann for the predictor.

9
00:00:44,690 --> 00:00:48,350
This creates another area which will call the forecast there at.

10
00:00:50,650 --> 00:00:54,490
Again, we've just launched the job, so we need to wait until it's complete.

11
00:00:56,780 --> 00:01:02,240
In the next block, we call the described forecast function passing in the air and for the forecast,

12
00:01:02,690 --> 00:01:06,080
once the status becomes active, then your forecast is ready.

13
00:01:06,770 --> 00:01:09,790
Note that when I ran this, it took approximately 10 minutes.

14
00:01:10,160 --> 00:01:15,410
So definitely much longer than it would take calling model to predict on your Tenzer flow model.

15
00:01:20,270 --> 00:01:22,670
So where is the forecast we've just created?

16
00:01:23,330 --> 00:01:27,710
Well, you'll recall that at the beginning of this script, we created two clients with boats of three.

17
00:01:28,250 --> 00:01:32,020
One was the forecast client and one was the forecast query client.

18
00:01:32,660 --> 00:01:37,580
Once we've generated our forecast, we can query it using the forecast query client.

19
00:01:39,840 --> 00:01:45,510
So the next thing we're going to do is call the query forecast function using the forecast query client,

20
00:01:46,230 --> 00:01:51,420
as mentioned previously, you're strongly encouraged to open up the Boto three documentation so you

21
00:01:51,420 --> 00:01:53,830
can see all these functions and arguments for yourself.

22
00:01:54,270 --> 00:01:58,050
I'm showing you what I've used, but be aware that there are still more options.

23
00:01:59,160 --> 00:02:01,980
So when we call this function, we're going to pass in the forecast.

24
00:02:01,980 --> 00:02:03,840
They are in which we just got it.

25
00:02:04,080 --> 00:02:10,350
And the item ID we want to query, since we only have one item ID, this must be spy.

26
00:02:12,870 --> 00:02:18,180
The next step is to just look at the response to see what we got, if you inspect this yourself, you'll

27
00:02:18,180 --> 00:02:21,330
see that there are really three main arrays you can see there.

28
00:02:21,360 --> 00:02:26,910
We have a nested dictionary with the key forecast than the key predictions and the keep 10.

29
00:02:27,570 --> 00:02:30,180
This points to a list which contains dictionaries.

30
00:02:30,180 --> 00:02:34,590
And each of these dictionaries is essentially a data point in our forecast.

31
00:02:35,220 --> 00:02:40,530
The first element is the timestamp, and the second element is the value, which really is the predicted

32
00:02:40,530 --> 00:02:42,420
value at that time stamp.

33
00:02:43,170 --> 00:02:44,540
So what does it mean?

34
00:02:45,270 --> 00:02:51,240
As you recall, our forecast model generates three predictions, one for the 10 percent percentile,

35
00:02:51,420 --> 00:02:55,710
one for the 50 percent percentile and one for the 90 percent percentile.

36
00:02:56,250 --> 00:03:02,220
So if we scroll down, we can see the keys for P 50 and P 90 as well with their corresponding list of

37
00:03:02,220 --> 00:03:03,090
values.

38
00:03:07,130 --> 00:03:13,310
Our next goal is to put all this data into a data frame, so in order to do that, we're going to pass

39
00:03:13,310 --> 00:03:15,560
this data into a list of tuples.

40
00:03:16,040 --> 00:03:20,480
Each tuple will have a timestamp followed by each of the three percentiles.

41
00:03:21,440 --> 00:03:28,460
And this next function called Adewusi forecast, we're going to accept three dictionaries, D 10, D

42
00:03:28,460 --> 00:03:30,180
50, Endi 90.

43
00:03:30,980 --> 00:03:36,230
The basic idea is we're going to live through each of the lists we saw earlier in corresponding order.

44
00:03:36,860 --> 00:03:41,490
So each of these dictionaries we pass in should correspond to the same time stamp.

45
00:03:41,990 --> 00:03:45,140
You might want to write a function to verify that this is the case.

46
00:03:46,500 --> 00:03:52,890
Inside the function, we first grab the timestamp key and cast this to a pan as timestamp, as you recall,

47
00:03:52,890 --> 00:03:59,250
the value returned by Adewusi is a string, but the panda's time stamp constructor can pass this automatically.

48
00:04:00,510 --> 00:04:04,980
Next, we obtain the three values, which I've just called eval one, eval two and three.

49
00:04:05,760 --> 00:04:09,900
Finally, this function returns each of the four items we just described.

50
00:04:13,480 --> 00:04:19,380
Next, to make things a little clearer, we're going to index the forecast response to grab the and

51
00:04:19,460 --> 00:04:21,540
P 50 and P 90 list.

52
00:04:22,060 --> 00:04:26,680
After that, we're going to use the zip function to loop through each list in parallel.

53
00:04:26,890 --> 00:04:30,340
So we visit each of the corresponding items at the same time.

54
00:04:31,180 --> 00:04:34,450
We then pass each of these items into the function we just created.

55
00:04:35,230 --> 00:04:37,180
We call the result of that past.

56
00:04:38,950 --> 00:04:45,820
Next, we create a new data frame out of our list of tuples, giving it the column names Timestamp 10,

57
00:04:45,970 --> 00:04:47,830
P fifty and P ninety.

58
00:04:49,310 --> 00:04:54,980
Next, we call the set index function on the time stamp column so that it becomes the index.

59
00:04:58,500 --> 00:05:03,510
The next step is to plot our forecast, along with the original Time series, to see how accurate it

60
00:05:03,510 --> 00:05:04,110
is.

61
00:05:04,740 --> 00:05:07,820
Note that in practice you're really going to predict the future.

62
00:05:08,040 --> 00:05:09,350
So this won't be possible.

63
00:05:09,840 --> 00:05:13,830
This lecture is more about seeing how good or bad eight of us forecast is.

64
00:05:15,180 --> 00:05:20,720
So we're going to create a new data frame which just indexes our old D.F. at the close column.

65
00:05:21,390 --> 00:05:23,010
We'll call this new data frame true.

66
00:05:23,010 --> 00:05:26,520
D.F. will then rename this single column to True.

67
00:05:28,140 --> 00:05:34,860
Next, we join Trudeau with the forecast D.F. we just created using an outer join, this will make it

68
00:05:34,860 --> 00:05:40,080
so that any dates not included in either data frame will just be filled with any ads.

69
00:05:40,650 --> 00:05:42,670
This is fine since they don't show up on the plot.

70
00:05:43,980 --> 00:05:47,070
Finally, we call the plot function and look at the results.

71
00:05:49,790 --> 00:05:54,730
As you can see, it doesn't look too bad, although the interesting part is perhaps a bit too small.

72
00:05:58,430 --> 00:06:03,770
In the next line, I've selected only the last one hundred data points and run the plot function again,

73
00:06:04,550 --> 00:06:08,390
this time we can see that in fact the forecast really isn't that bad.

74
00:06:08,840 --> 00:06:11,040
It seems to predict the trend fairly well.

75
00:06:11,660 --> 00:06:16,790
Interestingly, it predicts that the price will fall and then go back up, which is what happens, although

76
00:06:16,790 --> 00:06:18,440
not exactly at the same time.

77
00:06:19,250 --> 00:06:25,320
Furthermore, we can see that the true value goes above the 90 percent percentile for most of the forecast.

78
00:06:25,940 --> 00:06:31,820
However, it's important to note that the market was performing unexpectedly well during this time after

79
00:06:31,820 --> 00:06:33,170
the crash of twenty twenty.

80
00:06:34,530 --> 00:06:40,200
So as an exercise, you may want to implement a quantitative evaluation metric and compare the results

81
00:06:40,200 --> 00:06:44,100
of this forecast with something else you implemented in this course.
