added naive and s.naive MAE/RMSE
parent
b5bbc0e7cc
commit
b20c1d5e51
|
@ -64,7 +64,7 @@
|
|||
"\n",
|
||||
"np.set_printoptions(precision = 6, suppress = True)\n",
|
||||
"\n",
|
||||
"df = pd.read_csv('datasets/climate/jena_climate_2009_2016.csv')\n",
|
||||
"df = pd.read_csv('../data/jena_climate_2009_2016.csv')\n",
|
||||
"df.shape"
|
||||
]
|
||||
},
|
||||
|
@ -892,7 +892,7 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": 11,
|
||||
"execution_count": 16,
|
||||
"metadata": {
|
||||
"scrolled": true
|
||||
},
|
||||
|
@ -901,12 +901,23 @@
|
|||
"name": "stdout",
|
||||
"output_type": "stream",
|
||||
"text": [
|
||||
"LightGBM\n",
|
||||
"MAE: 2.083323119819872\n",
|
||||
"RMSE: 2.7826767013777443\n"
|
||||
"RMSE: 2.7826767013777443\n",
|
||||
"\n",
|
||||
"Naive\n",
|
||||
"MAE: 3.184767754022055\n",
|
||||
"RMSE: 4.457663461439199\n",
|
||||
"\n",
|
||||
"Seasonal Naive\n",
|
||||
"MAE: 2.613232738911751\n",
|
||||
"RMSE: 3.4171095400347133\n"
|
||||
]
|
||||
}
|
||||
],
|
||||
"source": [
|
||||
"### LightGBM\n",
|
||||
"\n",
|
||||
"recursive_x = test_x\n",
|
||||
"forecast_ms = []\n",
|
||||
"for j in range(prediction_horizon):\n",
|
||||
|
@ -914,13 +925,33 @@
|
|||
" recursive_x = np.hstack((recursive_x[:, 1:], pred[:, np.newaxis]))\n",
|
||||
" forecast_ms.append(pred)\n",
|
||||
"forecast_ms = np.asarray(forecast_ms).T\n",
|
||||
"print('LightGBM')\n",
|
||||
"print('MAE:', np.mean(np.abs(test_y - forecast_ms)))\n",
|
||||
"print('RMSE:', np.sqrt(np.mean((test_y - forecast_ms)**2)))\n",
|
||||
"print('')\n",
|
||||
"\n",
|
||||
"#mape_vals = (test_y - forecast_ms)/test_y\n",
|
||||
"#mape_vals[mape_vals == np.inf] = 0\n",
|
||||
"#mape_vals[mape_vals == -np.inf] = 0\n",
|
||||
"#print('MAPE:', np.nanmean(np.abs((mape_vals))))"
|
||||
"### Naive\n",
|
||||
"\n",
|
||||
"tmp = test_y[:-1, -1]\n",
|
||||
"n_forecast = []\n",
|
||||
"\n",
|
||||
"for val in tmp:\n",
|
||||
" n_forecast.append(np.repeat(val, 24))\n",
|
||||
"n_forecast = np.asarray(n_forecast)\n",
|
||||
"\n",
|
||||
"print('Naive')\n",
|
||||
"print('MAE:', np.mean(np.abs(test_y[1:, :] - n_forecast)))\n",
|
||||
"print('RMSE:', np.sqrt(np.mean((test_y[1:, :] - n_forecast)**2)))\n",
|
||||
"print('')\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"### S.Naive\n",
|
||||
"\n",
|
||||
"new_test = np.vstack(np.array_split(test_series.to_numpy()[3:], 730))\n",
|
||||
"\n",
|
||||
"print('Seasonal Naive')\n",
|
||||
"print('MAE:', np.mean(np.abs(new_test[1:, :] - new_test[:-1, :])))\n",
|
||||
"print('RMSE:', np.sqrt(np.mean((new_test[1:, :] - new_test[:-1, :])**2)))"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue