OK, so in this lecture, we are going to look at how to apply the code we just learned to a stock price
time series.
Now, one thing I want you to notice about this lecture is that it does not require any new code.
Only the data set has changed.
In fact, you should already have this data set from the previous exercises.
So if you'd like to stop this video and try to do this yourself, please take this opportunity to do
so now.
Otherwise, we'll continue.
Also note that I'm not exaggerating when I say that this did not require any new code.
I simply took the previous script change that you were all of the data set and changed the column names.
So if you're ever wondering what I mean by all data is the same.
This is a great example.
However, you should be aware of the fact that the statement does not imply you will get the same results.
In other words, just because you can forecast champagne sales with near perfect accuracy does not mean
you can do the same with stock prices.
OK, so let's scroll down to the part of the code where we load in our data.
As you recall, this CSV contains multiple stocks, so I'm going to call it D.F. Zero.
I've arbitrarily chosen IBM for this script, and so we're going to call the closed prices for the IBM
data frame D.F..
OK, so all this stuff is the same as before we take the log, we compute the difference, do a train
to split and so forth.
Now, remember, these are stock prices, so we pretty much have to make it stationary unless we want
a model that just predicts the last value.
OK, so let's look at how our linear model performs.
As you can see, the train R-squared is nearly zero and the test R-squared is worse than zero.
Let's not look at a plot of the One-Step forecast.
OK, so as you can see, it simply lags the input time series, which makes sense given what we know.
OK, so let's look at the multi step linear model forecast.
And so we see that the multistep forecast pretty much follows the straight line, which makes sense
given what we know.
So now let's do our multi output forecast.
Again, the R-squared is only slightly better than zero, which suggests that our data is just noise.
And so we see that the multi output forecasts pretty much follows the same pattern.
So interestingly, when we check the map, it doesn't seem too bad.
This should tell you that these numbers take some interpretation.
OK, so the next step is to try our non-linear models, maybe, perhaps there is some non-linear relationship.
OK, so let's check out the SVR.
So the SVR pretty much does the same thing.
Now let's see the random forest.
Again, pretty much the same thing.
Notice how well the random forest over fits the train said.
OK, now let's have a look at our multi output forecast.
And we see that it's pretty much the same results.
No surprise.
Now, what is the lesson of this example?
Well, you may have been hopeful that perhaps it was only linear models that would fail at predicting
stock returns.
Maybe you hopes that there were some nonlinear patterns waiting to be exploited.
But so far, it turns out that this has not been the case.