Facebook先知,Python中的非日常数据

时间:2018-04-06 16:05:36

标签: python facebook-prophet

我有几个半小时的数据超过几个非。它的形式如下:

05/10/2017 00:00:00,    116.297
05/10/2017 00:30:00,    7.3748
05/10/2017 01:00:00,    -94.8402
05/10/2017 01:30:00,    41.0546
05/10/2017 02:00:00,    206.3658
05/10/2017 02:30:00,    -283.0569
05/10/2017 03:00:00,    -656.2
05/10/2017 03:30:00,    631.2834

我想预测接下来的24小时(所以48小时半小时)。我的代码似乎给出了比这更长的预测。见情节:

enter image description here

这是:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from fbprophet import Prophet

# Load data
file_name = "test_data.csv"
df = pd.read_csv(file_name,parse_dates=[0])

#Fit the model
m = Prophet().fit(df)

#Make predictions
future = m.make_future_dataframe(periods=48, freq=H)

fcst = m.predict(future)
m.plot(fcst)
plt.show()

我没有正确设置make_future_dataframe方法吗?

2 个答案:

答案 0 :(得分:3)

您想要接下来的24小时,即1天(48个半小时)
如果要获取半小时的预测,则应设置freq='30min'

future = m.make_future_dataframe(periods=48, freq='30min')

此未来变量将具有接下来的48个半小时周期。

我希望这会对您有所帮助。

答案 1 :(得分:1)

Here是对可接受的freq参数别名的引用

这意味着这应该适合你

future = m.make_future_dataframe(periods=24, freq='H')

尝试设置periods=24,因为现在以小时为单位指定了频率