In this lecture, we are going to learn how to implement, walk forward validation for any of the time
series technique.
So here we will implement, walk forward validation for auto regression model.
This is what we are going to do.
We will run a for loop for all the values of test.
So suppose this is our test sites.
We have a test size of five units.
We will create individual Morton for each of the test value prediction.
Then in the next step of fall, Lou, we will increase our training dataset to include the new information.
Then we will again create a new model and forecast for a one time period ahead in the next loop.
We will again include the additional data and the word training data and create a new model.
And then again, forecast for one time period ahead.
We will do this for any number of things where and this the number of test values.
So if we want to predict five best values, we will run this loop for five times.
If we want to predict six values.
We will run this low for six times.
So let's look at a word for loop one small.
Before that, I have loaded my data into beer and I have created a sentry inside that set consists of
seven values.
So this is what we are going to do.
We are creating a new dataset that is data.
This is the data set in which we are going to add the word test values for future predictions.
So we are initiating this data as data and we are also creating a blank list with the name of credit
in this list.
We will install the predicted values of by.
So here I am initiating the for loop we are using for B in test.
So suppose if my test, if someone will use this for loop, will run four to seven times, if my test
has five values, this one loop will run for five things.
So let's analyze the first run for the first run.
My data is equal to cream, will create a model object with auto regulation on our data.
Again, since this is the first in my data is required to train.
And then we had Pettingill more than using Mordialloc it.
Then we are predicting the VI with a start tequilla full length of data and and equate to land of green
plus lente of test minus one.
This is similar to what we did for auto regression model.
So here and the first then my wife will consist of seven values.
Since my Astarte is the start of test and the end of tests.
Some way here will consist of seven values in the first one.
Next, we are picking the first value of this.
Why did the frame?
And then we are displaying that value and we are also appending that value in the word predict the duffing.
So this will be my first value.
If this is the first one, then in the input offer.
What model?
Which is data.
I am finding the value of test data.
So only I suppose my dream data or data had hundred records at the end of this loop.
My dream data that this data will have.
Hundred and one records.
So we are including this amount of data.
And do what?
Training data.
Now, let's analyze the second loop.
So now my data have all littering data, plus the first value of test data.
No, I'm creating my model on that data.
Now we are predicting why using landform data and then the endpoint.
So this time my very variable will contain six values.
We have already predicted one way.
Forty plus one.
So now this time, the Wyvill consists value from P plus two, two peoples seven.
Then again, we are picking the first value of this predicted way and we are also finding this value
and do not predict list.
So now my prediction list at the end of second run for loop will contain P plus one by value, which
was coming from the Force10 and Peoples through a loop, which is coming from the second grade.
And again, I am appending the test value into my dataset.
We will run this same sequence 47 times and at the end of this we will never predict list which will
contain the Vork forward validation y values.
So let's run this.
You can see we are getting this.
Lose US output, as we have also mentioned, the print segment in between.
If we look at the prediction, this will also contain in the same values.
You can see we have a list of seven values which we got from the walk forward validation.
Now, let's look at the masc value of these validations.
So earlier, if you remember four auto regression, we were getting an MNC value of one point five.
Now, let's see.
What value we are going to get from walk forward validation?
You can see the MASC value is one point forty five.
So we have decreased our edit by using the walk forward validation.
If you compare it with knife forecast, in my forecast, we were getting masc value off more than three.
So this is the significant reduction.
And you can also see that we are getting improved accuracy using walk forward validation as compared
to our normal single model for all the values.
Now let's load this on graph as well.
You can see we have actual values in blue and the predicted values in red.
So MSU, when you concluded from work for validation, is much more reliable metrics of evaluating model
performance.
And we should always select Morton, which is giving us better accuracy on walk forward validation instead
of a single model validation.
So that's all we should do.
Walk forward validation.
Four time series data.
You can see that we can use this method for other models as well.
So if we are applying moving average or Atima, we can just edit this model fit and model part to implement
walk forward validation.
Thank you.