我刚开始学习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()发布于 2018-09-03 20:26:08
我不知道它是否仍然相关。您需要准备一个保存实际值的DataFrame,让我们称其为df_actual。然后,以下代码将为您计算RMSE:
se = np.square(forecast.loc[:, 'yhat'] - df_actual)
mse = np.mean(se)
rmse = np.sqrt(mse)希望这能有所帮助。
https://stackoverflow.com/questions/51063282
复制相似问题