1
00:00:11,110 --> 00:00:16,240
So in this video, we will continue looking at how to implement vector out of aggression in Python.

2
00:00:16,990 --> 00:00:20,970
This lecture will continue where we left off, where we've just learned how to use Varma.

3
00:00:21,580 --> 00:00:25,090
The next step will be to test of Arpit model to see how it performs.

4
00:00:25,720 --> 00:00:30,320
So we'll start by creating of our object, passing in the train set as before.

5
00:00:30,970 --> 00:00:33,520
Note that at this point we do not pass in ENPI.

6
00:00:38,430 --> 00:00:43,470
The next step is to call the select order function to see what the different information criteria would

7
00:00:43,470 --> 00:00:44,080
select.

8
00:00:44,580 --> 00:00:49,920
Not that I've arbitrarily chosen Max LAG's equals 15, but you can feel free to try other values.

9
00:00:53,130 --> 00:00:56,910
OK, so you can see that this returns a leg order results objet.

10
00:00:58,910 --> 00:01:01,760
The next step is to print out the selected orders attribute.

11
00:01:05,010 --> 00:01:10,670
OK, so this is a dictionary where the key is the information criterion and the value is the order chosen

12
00:01:10,860 --> 00:01:14,850
if we use that criteria on notice that they do not all agree.

13
00:01:17,780 --> 00:01:23,080
The next step is to call model that fit passing in the max lags and information criterion again.

14
00:01:23,720 --> 00:01:28,190
Now, because we've had to do this, it should be clear that calling select order doesn't really have

15
00:01:28,190 --> 00:01:28,990
any impact.

16
00:01:29,360 --> 00:01:31,420
So that step isn't strictly necessary.

17
00:01:31,760 --> 00:01:37,010
You should use that for information only, but it doesn't affect how the model is actually estimated.

18
00:01:39,970 --> 00:01:43,270
OK, so notice how this train's much faster compared to Vamo.

19
00:01:46,010 --> 00:01:49,060
The next step is to get the gag order chosen by the AIC.

20
00:01:49,550 --> 00:01:52,070
Note that this is stored in an attribute called K.

21
00:01:52,070 --> 00:01:53,240
Underscore R.

22
00:01:57,470 --> 00:02:02,780
The next step is to call the forecast function, but as you recall before doing so, we need to also

23
00:02:02,780 --> 00:02:05,260
pass in the prior values of the Time series.

24
00:02:05,660 --> 00:02:10,700
This works differently than the other models we've seen, which only allow you to forecast after the

25
00:02:10,700 --> 00:02:12,710
data you passed into the constructor.

26
00:02:13,610 --> 00:02:17,440
So here we call trained on look and grab the last leg or values.

27
00:02:18,200 --> 00:02:21,740
The next step is to index the result at the relevant columns.

28
00:02:22,280 --> 00:02:25,110
The third step is to convert it into an umpire, Ray.

29
00:02:25,820 --> 00:02:31,310
You'll notice that in the documentation that the forecast function input is specified as an umpire.

30
00:02:31,310 --> 00:02:36,490
Ray, this is unlike the other functions we've seen in static models which work with data frames.

31
00:02:36,920 --> 00:02:41,120
So we'll call this the prior not to be confused with other uses of the same word.

32
00:02:41,330 --> 00:02:47,090
For example, in Bayesian machine learning, the next step is to call the forecast function passing

33
00:02:47,090 --> 00:02:51,500
in our prior time series along with and test the number of steps to forecast.

34
00:02:52,580 --> 00:02:58,070
Now, again, note that this API is not like the other models we've seen, so this does not return a

35
00:02:58,070 --> 00:02:58,850
forecast result.

36
00:02:58,850 --> 00:03:02,420
Objects instead of this just returns an array.

37
00:03:02,840 --> 00:03:05,810
If you want to print this out to confirm that, please do.

38
00:03:10,630 --> 00:03:13,570
The next step is to store our predictions in our data frame.

39
00:03:14,170 --> 00:03:20,160
So for the train set, we simply call the fitted values attribute as before for the test set.

40
00:03:20,320 --> 00:03:25,450
Since the prediction is an umpire, Ray, we're going to index the array at the zero with column.

41
00:03:25,960 --> 00:03:29,390
This is because Aukland comes before Stockholm in our data frame.

42
00:03:30,610 --> 00:03:34,990
The next step is to plot the last one hundred steps of our prediction as before.

43
00:03:40,580 --> 00:03:43,370
OK, so we can see that our forecast looks pretty good.

44
00:03:46,730 --> 00:03:50,760
The next step is to do the same thing, except for Stockholm instead of Auckland.

45
00:03:51,290 --> 00:03:55,820
Note that this time we index the forecast in column one instead of column zero.

46
00:04:02,120 --> 00:04:05,180
OK, so again, we see that our forecast looks pretty good.

47
00:04:09,000 --> 00:04:14,760
The next step is to compute the square of our predictions, since this code is exactly the same as before.

48
00:04:14,940 --> 00:04:16,230
I won't explain it again.

49
00:04:19,990 --> 00:04:24,220
OK, so for Auckland, it looks like our forecast is not as good as Varma.

50
00:04:27,120 --> 00:04:29,640
The next step is to look at the R-squared for Stogel.

51
00:04:34,550 --> 00:04:37,930
And again, we see that our forecast is not as good as Varma.

52
00:04:40,870 --> 00:04:45,640
OK, so the next step is to establish a baseline, which will be just pure Arima.

53
00:04:48,190 --> 00:04:50,890
So we'll begin by importing the Arima class.

54
00:04:54,820 --> 00:05:01,300
The next step is to build and evaluate an Arima for every column in our data set individually so you

55
00:05:01,300 --> 00:05:06,580
can see that we loop through each column in our list of columns inside the loop, we create an Arima

56
00:05:06,580 --> 00:05:11,580
object with pixels 10 and Q equals 10, which is the same as before.

57
00:05:12,100 --> 00:05:14,050
But note that in total is a rhema.

58
00:05:14,050 --> 00:05:19,040
Models have fewer parameters than Varma since they do not contain any cross terms.

59
00:05:19,960 --> 00:05:23,410
The next step is to get the forecast for test time steps.

60
00:05:24,220 --> 00:05:27,700
The next step is to compute the square for both train and test.

61
00:05:28,310 --> 00:05:29,770
OK, so let's run this.

62
00:05:39,280 --> 00:05:45,940
So we see that for both Auckland and Stockholm, our Arima baseline does better the square to smaller,

63
00:05:46,060 --> 00:05:47,610
but the test, our square is larger.

64
00:05:48,100 --> 00:05:51,700
This means that these models overfit less intuitively.

65
00:05:51,730 --> 00:05:56,490
We might understand that this should be the case since the two cities we chose are far apart.

66
00:05:57,100 --> 00:06:02,230
So it could be the case that their weather does not have any effect on each other, in which case any

67
00:06:02,230 --> 00:06:04,720
correlation we find is due to noise.

68
00:06:05,710 --> 00:06:09,850
Using a arima eliminates those cross terms, which removes that possibility.

69
00:06:10,630 --> 00:06:15,970
As always, it's best to simply check, to see what works best and to choose the model that outperforms

70
00:06:15,970 --> 00:06:16,750
the others.

71
00:06:17,290 --> 00:06:20,620
In this case, it appears that our baseline is the better choice.
