So in this lecture, we are going to discuss how to do change point detection with profit.
Now, as you recall, the change points are actually detected automatically when we call fit because
they are actually part of the model.
This lecture is only about how to visualize what the model has found.
So we'll begin by importing the function, add change points to plot.
The next step is to call em plot passing in the forecast we made earlier, as you recall, you already
know how to do this step, which plots both the original Time series, along with the predictions.
The next step is to simply add the change points on top of that plot by calling the function we just
imported.
OK, so our plot shows that we have one change point where the trend goes from more sleep to less deep,
as you recall, this is what we saw earlier when we plotted the trend to component.
The second step is to do the same thing, but with our second model, M2.
OK, so notice that this time we have many change points within a small area.
Recall that these are governed by the priors so the priors can be tuned to increase or decrease the
sensitivity of the change points.
Remember that by default, the model sets twenty five potential change points in the first 80 percent
of the training data.
So basically what's happening is it's choosing change points from among those twenty five.
So that explains why these change points are equally spaced.
The next step is to do the same thing, but with our third model M three.
So, again, we get pretty much the same result, which is not unexpected.
Now, in this next portion, we're going to see what happens when we tune the prior for change point
detection, the text you see here is copied from the Facebook documentation for a convenience.
So notice that the default is zero point zero five.
If you increase this value, it makes the trend more flexible.
And if you decrease this value, it makes the trend less flexible.
So the next step is to fit a new model with the prior set to zero point five.
This is larger than before, so it will make the change points more flexible.
OK, so as you can see, we now get more change points, which makes sense.
The next step is to try the same thing, but with our second data set, DFB two were the days where
the store is closed or removed again and notice that have increased the prior scale by a factor of 10.
So, again, we see more change points and they aren't all bunched up in one area like before.
So what this tells us is that including all those zeros affects how the change points are detected.
One might consider this to be a cleaner signal.
The next step is to use the same data set again, but this time will decrease the change point prior
by a factor of 10.
This should result in us having less change points.
So, as expected, we have less change points than before.
In fact, we have none.