【发布时间】:2020-08-17 14:15:37
【问题描述】:
我有一个时间序列数据如下:
ds y
0 2016-10-31 2000
1 2016-11-30 3000
2 2016-12-31 5000
3 2017-01-31 5000
4 2017-02-28 4000
5 2017-03-31 4500
6 2017-04-30 10000
7 2017-05-31 6500
8 2017-06-30 3500
9 2017-07-31 5500
10 2017-08-31 2000
11 2017-09-30 3000
12 2017-10-31 10000
13 2017-11-30 5000
14 2017-12-31 4000
15 2018-01-31 4500
16 2018-02-28 5000
17 2018-03-31 6500
18 2018-04-30 3500
19 2018-05-31 5500
20 2018-06-30 2000
21 2018-07-31 3000
22 2018-08-31 10000
23 2018-09-30 5000
24 2018-10-31 4000
25 2018-11-30 4500
26 2018-12-31 5000
27 2019-01-31 6500
28 2019-02-28 3500
29 2019-03-31 5500
我已经应用了 FB Prophet 变化点检测算法来提取变化点。
当我在代码中指定 5 个变更点时,我得到以下变更点:
5 2017-03-31
9 2017-07-31
14 2017-12-31
18 2018-04-30
23 2018-09-30
当我在代码中指定 7 个变更点时,我得到以下变更点:
3 2017-01-31
7 2017-05-31
10 2017-08-31
13 2017-11-30
16 2018-02-28
20 2018-06-30
23 2018-09-30
为什么算法没有检测到与前一点相比值变化最大的点 6、12、22?
我的代码如下:
from fbprophet import Prophet
import pandas as pd
import matplotlib.pyplot as plt
m = Prophet(growth='linear', n_changepoints = 7, changepoint_range=0.8, changepoint_prior_scale=0.5)
m.fit(df)
future = m.make_future_dataframe(freq = 'M', periods=3)
fcst = m.predict(future)
from fbprophet.plot import add_changepoints_to_plot
fig = m.plot(fcst)
a = add_changepoints_to_plot(fig.gca(), m, fcst)
m.changepoints
【问题讨论】:
标签: python-3.x forecasting trend facebook-prophet