OK, so in this lecture, we are going to look at applying the whole Winsor's model to a new data center,
specifically stock prices.
Now, before we begin this lecture, I want to give you an opportunity to stop this video and to try
to do this on your own.
Since you've already learned all the code you need to complete this exercise, you technically do not
need my help.
So if you want to treat this as an exercise, please download the data set from the euro given in this
notebook.
But after you get the euro, close the notebook and build a model on your own.
OK, so if you want to try this as an exercise, please do so now.
Otherwise, let's continue.
OK, so let's skip the imports since you have seen this all before.
The next step is to download our data, so clearly this is a CSFI of stock prices for stocks in the
S&P 500.
Well, now run the head commands in order to check what's inside our CSFI.
Note that unlike a typical stock price, GSV, this contains multiple tickers at once, you can see
that it's essentially multiple ticker's concatenated in the same data frame.
You can tell them apart by the name column.
The next step is to load in our data using Pediatrics V..
The next step is to call the head to see what's in our data frame.
OK, so nothing unexpected.
The next step is to grab the clothes prices for Google.
Please feel free to choose your own ticker if you like.
The next step is to call the plot function to see what our data looks like.
OK, so we see that Google is performing very well in the stock market.
The next step is to take the log transform of the close price, we'll also plot this new column to see
what it looks like.
Interestingly, we can now see a pretty linear trend.
So you'll notice that I've commented on this line, which does not work.
So the problem with stock prices is they only exist for trading days.
However, trading days are not evenly spaced in time.
Furthermore, they don't correspond with business days, which is the closest thing in panties.
Unfortunately, this line throws an error.
So we'll just have to make do without having a frequency for the index.
The next step is to split our data into training tests I've chosen and testicles 30, which might be
a bit long.
So feel free to change this to whatever you like.
OK, so you've seen this before.
OK, so the next step is to instantiate our model, since I don't believe this data has any seasonality.
I've said Seasonale to none again.
Feel free to test different parameters and see what works best.
Note that we technically didn't have to take the log ourselves, since that's models can do this internally,
also observe that we get a warning since our data frame index doesn't have a frequency.
The next step is to assign our predictions to the Google data frame.
For the test set, you see that I've converted the result into an umpire, Ray.
This is because not having a frequency for the index messes up the forecast indices and this will mess
up where it goes in the data frame.
OK, so the next step is to plot our predictions.
Notice how nice they look for the train set, but don't be fooled.
Of course, what really matters is the test said.
OK, so in order to get a better picture of what's going on, we're going to plot only the last one
hundred data points.
So the result is not too surprising.
We see that our model only appears to do well on the train set because it copies the last value.
This makes sense since the log price nearly follows a random walk.
And of course, the forecast is a straight line since we've used holds linear trend model to fit our
data set as an exercise.
Try to compute one of our forecasting metrics for this prediction and compare it to the night forecast.
Remember that for the naive forecast, we have to propagate the last known value through the forecast
horizon.
So don't copy the last value within the test set, but only copy the last value from the train set.
This should give you a horizontal line.
So in other words, see if a horizontal line is better than Holtze.
Linear trend line.