-1

I have two time series (forecast and realization) and both start as of 2003 until today. I need to calculate the RMSE for each month and for each year. Could you please help me with the code. I used np.sqrt(metrics.mean_squared_error(actual, forecast)) but it gives RMSE for the whole set. Many thanks!

The data loos like this enter image description here

Tochiza
  • 9
  • 1
  • 1

1 Answers1

0

I assume your data is a pandas dataframe. If so, you want to group by months and then aggregate by rmse:

from sklearn.metrics import mean_squared_error
df["differ"] = df["Forecast"] - df["Actual"]
rmseser = df.groupby(['Year', 'Month']).differ.agg(lambda x: sqrt(np.sum(x * x))
Igor Rivin
  • 4,632
  • 2
  • 23
  • 35
  • it seems that it's not working at my end - I got "'DataFrameGroupBy' object has no attribute 'differ'" – Tochiza Jul 01 '20 at 19:59