【发布时间】:2018-05-15 14:01:34
【问题描述】:
我正在尝试使用先知包来预测时间序列:
首先我将月份和日期合并为一列:
df1['Date'] = pd.to_datetime(df1.Ano.astype(str) + '-' + df1.Meses.astype(str))
我的数据框:
Date Values
11259 2017-01-01 23.818044
11286 2017-02-01 20.275252
11313 2017-03-01 22.347278
11340 2017-04-01 23.837490
11367 2017-05-01 23.460605
11394 2017-06-01 22.307115
11421 2017-07-01 23.643994
11448 2017-08-01 23.791720
11475 2017-09-01 23.643933
11502 2017-10-01 20.771269
11529 2017-11-01 21.317947
11556 2017-12-01 22.361570
33723 2018-01-01 24.336259
33750 2018-02-01 19.926928
33777 2018-03-01 22.714901
33804 2018-04-01 23.605119
33831 2018-05-01 23.653298
33858 2018-06-01 23.052182
33885 2018-07-01 24.377920
33912 2018-08-01 24.576733
33939 2018-09-01 24.376775
33966 2018-10-01 21.256970
33993 2018-11-01 21.969202
34020 2018-12-01 22.970637
然后我尝试使用以下功能:
sub_model = Prophet(interval_width=0.95)
sub_model.fit(df1)
然后我得到以下错误:
KeyError: 'y'
During handling of the above exception, another exception occurred:
KeyError Traceback (most recent call last)
<ipython-input-6-a31a513027be> in <module>()
31
32 sub_model = Prophet(interval_width=0.95)
---> 33 sub_model.fit(df1)
34
我的年月日专栏有什么问题与先知功能冲突吗?
更新:按照 Vasil 的建议,第一个解决方案是将日期列名称更改为“ds”,将变量列更改为“y”。
现在,出现错误消息:
INFO:fbprophet.forecaster:n_changepoints greater than number of observations.Using 18.0.
指的是这个函数:
# the history.
hist.size <- floor(nrow(m$history) * .8)
if (m$n.changepoints + 1 > hist.size) {
m$n.changepoints <- hist.size - 1
message('n.changepoints greater than number of observations. Using ',
m$n.changepoints)
}
更新:添加 alec_djinn 建议的 n_changepoints 参数解决了第二个问题
最后一个问题是第二条消息:
Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
【问题讨论】:
-
尝试明确传递
n_changepointsProphet(interval_width=0.95, n_changepoints=5)5 当然可以更改。在这里查看实现细节github.com/facebook/prophet/blob/master/python/fbprophet/…
标签: python forecasting facebook-prophet