【问题标题】:Calculating RMSE for Prophet Model in Python在 Python 中计算 Prophet 模型的 RMSE
【发布时间】:2018-12-06 09:05:46
【问题描述】:

我是学习 Python 的新手,我正在创建一个时间序列模型,该模型使用 Prophet 模型预测每个月的总销售额。我需要帮助来获取模型的 RMSE!谢谢!

from fbprophet import Prophet
#Creating Dataframe#
proph = train.groupby(['date_block_num'])[ 'item_cnt_day'].sum()
proph.index=pd.date_range(start='2013-01-01', end='2015-10-01', freq='MS')
proph = proph.to_frame().reset_index()
proph.columns = ['ds', 'y']
proph.head()
#Modelling#
model=Prophet(yearly_seasonality=True)
model.fit(proph)
model.head()
#Making future predictions
future_data = model.make_future_dataframe(periods=1, freq='MS')
forecast = model.predict(future_data)
forecast[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].tail()

【问题讨论】:

    标签: python time-series statsmodels facebook-prophet forecast


    【解决方案1】:

    我不知道它是否仍然相关。您需要准备一个保存实际值的 DataFrame,我们称之为df_actual。然后下面将为您计算 RMSE:

    se = np.square(forecast.loc[:, 'yhat'] - df_actual)
    mse = np.mean(se)
    rmse = np.sqrt(mse)
    

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-03
      • 1970-01-01
      • 2021-09-02
      • 2021-12-29
      • 2016-06-25
      • 2015-10-26
      • 2019-09-08
      • 1970-01-01
      相关资源
      最近更新 更多