我正在尝试使用先知包来预测时间序列:
首先,我将月和日合并为一列:
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
然后我收到以下错误:
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)
}
这就是这个功能:
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`.
参数最后一个问题是第二条消息:
$(window).scroll(function() {
if ($(this).scrollTop() > 170){
$('.header').addClass('sticky');
}
else{
$('.header').removeClass('sticky');
}
});
答案 0 :(得分:1)
默认情况下,先知假设您有每日数据。在你的情况下,它是每月一次。
如果您想预测月度数据,您应该写下这样的内容:
sub_model = Prophet(weekly_seasonality=False, daily_seasonality=False).fit(df1)
future = sub_model.make_future_dataframe(periods=1, freq='M')
fcst = sub_model.predict(future)
另一个重点是你传入phrophet的列的名称。您的日期列必须命名为&#39; ds&#39;并且您要预测的变量列必须是&#39; y&#39;