OK, so in this lecture, we are going to continue our investigation into applying machine learning
to the airline passengers time series.
So this script is going to have the exact same structure as the previous script.
We're going to go through all the same steps in the exact same order.
The only difference, no pun intended, is that in this case, we are going to make the time series
stationary by taking the first difference.
The implication of this is that when we want to compute our forecast, we have to undo this different
saying.
Now, for some people, it might help to look at some math and for others it might help to just look
at the code.
So we're going to do both.
For me personally, I found just going straight to the code, more intuitive.
I didn't write down this math until I realized I had to make this lecture, but I decided to explain
the math, since it really helps to explain why we use those functions in the code.
OK, so suppose we've taken the first difference of our data will say Delta Y of T is just Y of T,
minus Y of T minus one.
Then our different data set is just Delta one, Delta Y two and so forth, this is the data we will
train on because of this.
Our model predictions will also be for this Difference Time series.
So Delta Y have one, Delta Y had two and so forth.
Now, let's suppose we would like to make a train prediction for the original Time series, for instance,
I want to know why hat t my model does not predict why hat t directly, but I do have Delta.
Why hat t?
I know that Delta why hat t is a prediction for Y of T minus Y of T minus one.
In this way, I can conceptually move Y of T minus one to the other side and say that my prediction
for Y of T is Y of T minus one plus Delta Y had.
So this is how I would make a forecast for an N sample prediction.
This is also how to do a one step forecast.
This makes sense because if today is T minus one that I know Y of T minus one, I do not know why of
T which is why I want to make a forecast of this value.
So I use my model to predict Delta Y of T, and then I add that to the current wave T minus one in order
to predict tomorrow's Y of T.
The next question to consider is how do we forecast the multiple times steps into the future beyond
the in sample data?
Well, let's begin with the fact that we know how to make multistep forecasts, either using the incremental
or the multi output method so we know how to obtain a Delta Y hat of big C plus one.
Delta Y had a big C plus two and so forth.
So we have all these deltas, but we need to go back to the original undifferentiated series.
Let's start with the first prediction at time.
That Big T plus one.
In this case, we can follow the same formula as before.
We just add the prediction for the next Delta to the last known value.
But how do we get the forecast for big C plus two?
Well, if we knew why a big T plus one, then we could just follow the usual formula.
But since we do not, then we do the next best thing, which is to plug in our prediction.
Why had of Big C plus one.
However, notice that we can just plug in the previous expression for we had a big C plus one in terms
of the last known value Y of Big T.
And of course, we can repeat this pattern for the forecast at time at Big T plus three in this case,
it's why Big T plus the next three deltas.
OK, so I hope you get the idea.
The forecast is just the cumulative some of the deltas added to the last known value in the Time series.