用Python计算Prophet模型的RMSE

问题描述 投票:1回答:1

我是学习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个回答
0
投票

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

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

希望这可以帮助。

© www.soinside.com 2019 - 2024. All rights reserved.