OK, so in this video, we will be looking at how to use profit in the previous video, we got our data
into the right format stored in a data frame called DFB.
So now we can go straight into creating our profit instant's.
The next step is to call fit passing in our data frame.
Note that during the editing process, Prophet Prince had some information, so here it is pointed out
that daily seasonality has been disabled.
Of course, this makes sense since our data is daily, in order to measure any daily seasonality, we
would need data on a finer scale.
Now that we fitted our model, the next step is to work on the process of making a prediction, as you
recall, this actually takes several steps.
So the first step is to call make future data frame.
This takes in an argument called periods.
So periods is the number of steps into the future you want to forecast.
So the next step is to call Futuregrowth head to see what we actually got back.
As you recall, when we make a so-called forecast, this will actually include predictions for both
in sample data and the future.
This is why we see dates starting from 2013, which is the start of our Time series.
Note also that this only contains a single column, which is the timestamp for each prediction.
So this data frame does not actually contain any predictions.
The next step is to call future ducktail.
So now we can see deeds going up to 20, 16, a 730, which, as you recall, is three hundred and sixty
five days beyond our Time series.
The next step is to make the actual forecast by calling Emerg predict this takes in the future data
frame we just created and gives us back a new data frame, which we will call forecast.
The next step is to call forecastable to see what we get back.
So as you can see, we get back quite a few columns, the first column is the timestamp, which corresponds
to the time stamps in our data frame called future.
The next column is treant.
So as you recall, profit models, each component separately, and thus the forecast contains predictions
for each individual component.
In addition to the final prediction, the next two columns are for while lower in a white hat upper,
which are the prediction intervals for white hat.
The next two columns are for trend lower and trend upper, which are the prediction intervals for the
trend.
Now, the next few columns are pretty self-explanatory, so I'll let you go through those on your own
if you choose the final column is Why Hat, which of course is our model prediction.
OK, so the next step is to plot our forecast, which, as you know, contains the sample prediction
as well.
As you recall, profit makes this very easy since everything is built into this function called plot.
OK, so here we have our model predictions, so what does this say?
Firstly, notice that our original time series data appears as a scatterplot of black dots.
Our model predictions are the thick blue line.
The corresponding prediction intervals are the transparent blue lines.
And of course, the forecast period is obvious since that's the period with no black dots.
Notice one peculiar feature of this prediction, which is that the model is not able to precisely determine
that sales should be zero on Sundays or when the store is not open, we can see that the prediction
for some of these days is negative and the prediction interval falls below zero.
So in that respect, this model does require human intervention to make sense of the predictions, although
we'll see better ways of dealing with this later.
Right now, we're just demonstrating the steps.
The next step is to call MWI component's.
So as you can see, this makes a nice plot for each component of the model.
Essentially, this will show the trend, seasonal components and holiday components if they exist.
So the first component is the trend, which we can see is decreasing over time.
Note that there is one point at which the trend changes.
The next component is the weekly component, as you can see, the impact of Sundays is very negative,
which makes sense given that we included Sundays in our Time series.
The final component is the yearly component, notice the large peak around the Christmas holiday, which
of course, makes sense.
OK, so the next step is to build another model, but to only include the days where the store is open,
this is because we already know that the store will have a zero sales on days that is closed.
So we'll start by selecting only the rows from the store, one data frame where open is not zero.
We'll also set the date column to be the index.
The next step is to call the head function to see what our new data frame looks like.
Notice the absence of zeros.
The next step is to rename our columns to winds as required.
The next step is to run through the usual steps of creating a model calling fit and making a prediction.
I've grouped these together since we already know how they work at this point.
OK, so notice that this time our forecast appears to make a lot more sense, this is because it no
longer has to model the zeros on the days where the stores closed.
One way we can see that this model is better.
Is that the prediction interval is much tighter.
So it no longer goes down to negative values.
However, one thing to be careful of is that the predictions for Sunday's and other days in which the
store is not open are no longer valid.
As you recall, the profit model is a continuous model, so it will have predictions for those days.
But as an analyst, we would simply ignore those predictions because we know they will be zero.
The next step is to plot the components of our new model predictions.
So, again, we see that the trend is piece wise, linear, with one change point where we have a steep
decrease at the start and a slower decrease for the rest.
For the weekly companion, notice that this is very different from before, the influence of Sunday
is no longer very negative, but rather high.
This is because we don't actually have any data for Sundays.
So the model is simply interpolating.
Again, if you were an analyst, you would simply ignore this due to your knowledge of the Time series.
When we look at the yearly component, we see the same pattern as before, where we see a large increase
over the winter holiday.