trend_changepoints.md (prophet-0.7) | : | trend_changepoints.md (prophet-1.0) | ||
---|---|---|---|---|
skipping to change at line 22 | skipping to change at line 22 | |||
id: specifying-the-locations-of-the-changepoints | id: specifying-the-locations-of-the-changepoints | |||
--- | --- | |||
You may have noticed in the earlier examples in this documentation that real tim e series frequently have abrupt changes in their trajectories. By default, Proph et will automatically detect these changepoints and will allow the trend to adap t appropriately. However, if you wish to have finer control over this process (e .g., Prophet missed a rate change, or is overfitting rate changes in the history ), then there are several input arguments you can use. | You may have noticed in the earlier examples in this documentation that real tim e series frequently have abrupt changes in their trajectories. By default, Proph et will automatically detect these changepoints and will allow the trend to adap t appropriately. However, if you wish to have finer control over this process (e .g., Prophet missed a rate change, or is overfitting rate changes in the history ), then there are several input arguments you can use. | |||
<a id="automatic-changepoint-detection-in-prophet"> </a> | <a id="automatic-changepoint-detection-in-prophet"> </a> | |||
### Automatic changepoint detection in Prophet | ### Automatic changepoint detection in Prophet | |||
Prophet detects changepoints by first specifying a large number of *potential ch angepoints* at which the rate is allowed to change. It then puts a sparse prior on the magnitudes of the rate changes (equivalent to L1 regularization) - this e ssentially means that Prophet has a large number of *possible* places where the rate can change, but will use as few of them as possible. Consider the Peyton Ma nning forecast from the Quickstart. By default, Prophet specifies 25 potential c hangepoints which are uniformly placed in the first 80% of the time series. The vertical lines in this figure indicate where the potential changepoints were pla ced: | Prophet detects changepoints by first specifying a large number of *potential ch angepoints* at which the rate is allowed to change. It then puts a sparse prior on the magnitudes of the rate changes (equivalent to L1 regularization) - this e ssentially means that Prophet has a large number of *possible* places where the rate can change, but will use as few of them as possible. Consider the Peyton Ma nning forecast from the Quickstart. By default, Prophet specifies 25 potential c hangepoints which are uniformly placed in the first 80% of the time series. The vertical lines in this figure indicate where the potential changepoints were pla ced: | |||
 | INFO:numexpr.utils:NumExpr defaulting to 8 threads. | |||
 | ||||
Even though we have a lot of places where the rate can possibly change, because of the sparse prior, most of these changepoints go unused. We can see this by pl otting the magnitude of the rate change at each changepoint: | Even though we have a lot of places where the rate can possibly change, because of the sparse prior, most of these changepoints go unused. We can see this by pl otting the magnitude of the rate change at each changepoint: | |||
 |  | |||
The number of potential changepoints can be set using the argument `n_changepoin ts`, but this is better tuned by adjusting the regularization. The locations of the signification changepoints can be visualized with: | The number of potential changepoints can be set using the argument `n_changepoin ts`, but this is better tuned by adjusting the regularization. The locations of the signification changepoints can be visualized with: | |||
```R | ```R | |||
# R | # R | |||
plot(m, forecast) + add_changepoints_to_plot(m) | plot(m, forecast) + add_changepoints_to_plot(m) | |||
``` | ``` | |||
```python | ```python | |||
# Python | # Python | |||
from fbprophet.plot import add_changepoints_to_plot | from prophet.plot import add_changepoints_to_plot | |||
fig = m.plot(forecast) | fig = m.plot(forecast) | |||
a = add_changepoints_to_plot(fig.gca(), m, forecast) | a = add_changepoints_to_plot(fig.gca(), m, forecast) | |||
``` | ``` | |||
 |  | |||
By default changepoints are only inferred for the first 80% of the time series i n order to have plenty of runway for projecting the trend forward and to avoid o verfitting fluctuations at the end of the time series. This default works in man y situations but not all, and can be changed using the `changepoint_range` argum ent. For example, `m = Prophet(changepoint_range=0.9)` in Python or `m <- prophe t(changepoint.range = 0.9)` in R will place potential changepoints in the first 90% of the time series. | By default changepoints are only inferred for the first 80% of the time series i n order to have plenty of runway for projecting the trend forward and to avoid o verfitting fluctuations at the end of the time series. This default works in man y situations but not all, and can be changed using the `changepoint_range` argum ent. For example, `m = Prophet(changepoint_range=0.9)` in Python or `m <- prophe t(changepoint.range = 0.9)` in R will place potential changepoints in the first 90% of the time series. | |||
<a id="adjusting-trend-flexibility"> </a> | <a id="adjusting-trend-flexibility"> </a> | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 4 lines changed or added |