gpt4 book ai didi

python - 仅在 Facebook Prophet 模型 Python 上绘制预测值

转载 作者:行者123 更新时间:2023-12-02 16:30:07 24 4
gpt4 key购买 nike

当我通过以下代码与 facebook 先知模型进行绘图时:

number_of_days_in_future = 20
future = m.make_future_dataframe(periods=number_of_days_in_future, freq="D")
weekend = future[future['ds'].dt.dayofweek < 5 ]
prediction = m.predict(weekend)
m.plot(prediction)
plt.title("Prediction of Value")
plt.xlabel("Date")
plt.ylabel("Value")
plt.show()

它显示了从历史数据开始的绘图,如下所示: Plotted

很难理解图中的值,因为它跨越了 Y 轴的大范围。

但如果我只预测几天。这样更容易理解 Y 轴的值:

enter image description here

我的问题是:

  1. 有什么方法可以让它不跨越这么大的范围吗? (如果我们可以忽略绘制阴影部分)
  2. 有没有办法只绘制尾部预测部分? (我不想绘制整个历史数据)

最佳答案

我刚刚从 fbprophet 存储库中找到了一种方法来满足我的要求。

fig = m.plot(prediction)
ax = fig.gca()
# setting x limit. date range to plot
ax.set_xlim(pd.to_datetime(['2020-08-19', '2020-08-25']))
# we can ignore the shadow part by setting y limit
ax.set_ylim([26, 29])

图表变得更清晰: enter image description here

关于python - 仅在 Facebook Prophet 模型 Python 上绘制预测值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63665400/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com