Ant*_*y W 6 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
Run Code Online (Sandbox Code Playgroud)
我想对接下来的 24 小时(即 48 个半小时)进行预测。我的代码似乎给出了比这更长的预测。见情节:
这里是:
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()
Run Code Online (Sandbox Code Playgroud)
我没有make_future_dataframe正确设置方法吗?
小智 8
您想要接下来的 24 小时,即 1 天(48 个半小时)如果您想获得每半小时的预测,
您应该设置freq='30min'以防万一。
future = m.make_future_dataframe(periods=48, freq='30min')
这个未来变量将有接下来的 48 个半小时周期。
我希望这会帮助你。
这是对可接受的频率参数别名的引用
这意味着这应该适合你
future = m.make_future_dataframe(periods=24, freq='H')
Run Code Online (Sandbox Code Playgroud)
尝试设置,periods=24因为现在以小时为单位指定频率