OK, so in this lecture, we are going to look at applying the whole Winters' model to a new data set.
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 the model on your own.
OK, so if you want to try this as an exercise, please do so now.
Otherwise, let's continue.
So we'll start by importing the usual libraries, pandas number matplotlib and the R-squared Metrick.
Now, there's no special reason I'm using this metric, so please feel free to choose your own.
Next, we're going to update stats models so that we have the latest version.
Next, we're going to download the data set, so this is a data set of champagne sales, typical sort
of TIME series for this kind of model.
We'll now run the head commands in order to check what's inside our CSFI.
So as you can see, the header looks kind of funky, so that's something we'll rename and pantos.
Next, we're going to call ESV to load in our data frame.
Note that there are two junk lines at the bottom of this CSFI file.
So we pass in a skip four equals two.
You might want to look at the file yourself to verify what I'm saying.
The next step is to do a DFG head to look at our data frame.
So pretty much what we expect the month is the index in the champagne sales are the one and only column.
The next step is to rename a column to be something nicer to deal with.
The next step is to plot our data center.
So here's what we notice about this data.
First, we recognize that there is seasonality in this data.
Second, we see that there might be a slight trend, but the seasonal pattern is definitely more obvious.
Third, note that the seasonal pattern is not constant, but seems to increase over time, at least
to a point.
OK, so the next step is to set the frequency of our index, which is in months.
The next step is to split our data into train and test will choose and test equals 12, which makes
sense since the seasonal cycle is one year.
The next step is to create a bullying series in order to index the train and Cicero's of our data frame.
The next step is to instantiate our whole Winsor's model.
Now, there's no particular reason I've chosen these options except for obviously the seasonal period,
which is 12.
Feel free to try other options and use what you've learned in the course.
Note that we're also going to fit the model in the same block.
The next step is to assign the predictions to our data frame, so we'll start with the sample data,
which will set to the whole winter's train.
Was that the out of sample data to the column?
Winter's Test, this is so that the train and test predictions appear in different colors.
The next step is to plot our predictions against the true data.
As you can see, it's a pretty reasonable fit.
OK, so the next step is to check the R-squared for both the train and test sets.
As you can see, we get a pretty high R-squared for the tests there, but not as high for the trains,
that this makes sense since as you saw on the playa, the model has a hard time predicting the very
high peaks in the data.
So you might want to try other options and see if that improves the performance.