Skip to content

Commit 1b6d977

Browse files
committed
Add the MAE score
1 parent cfbb091 commit 1b6d977

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

pysteps/verification/detcontscores.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ def det_cont_fcst(pred, obs, scores, **kwargs):
2525
+------------+----------------------------------------------------------------+
2626
| corr_s | spearman's correlation coefficient (rank correlation) |
2727
+------------+----------------------------------------------------------------+
28+
| MAE_add | mean absolute error of additive residuals |
29+
+------------+----------------------------------------------------------------+
30+
| MAE_mul | mean absolute error of multiplicative residuals |
31+
+------------+----------------------------------------------------------------+
2832
| ME_add | mean error or bias of additive residuals |
2933
+------------+----------------------------------------------------------------+
3034
| ME_mult | mean error or bias of multiplicative residuals |
@@ -77,6 +81,15 @@ def det_cont_fcst(pred, obs, scores, **kwargs):
7781

7882
score = score.lower()
7983

84+
# mean absolute error
85+
if score == 'mae_add':
86+
MAE_add = np.mean(np.abs(add_res))
87+
result.append(MAE_add)
88+
89+
if score == 'mae_mult':
90+
MAE_mult = np.mean(np.abs(mult_res))
91+
result.append(MAE_mult)
92+
8093
# mean error (stm called bias)
8194
if score == 'me_add':
8295
ME_add = np.mean(add_res)

pysteps/verification/interface.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ def get_method(name, type="deterministic"):
3939
+------------+----------------------------------------------------------+
4040
| corr_s | spearman's correlation coefficient (rank correlation) |
4141
+------------+----------------------------------------------------------+
42+
| MAE_add | mean absolute error of additive residuals |
43+
+------------+----------------------------------------------------------+
44+
| MAE_mul | mean absolute error of multiplicative residuals |
45+
+------------+----------------------------------------------------------+
4246
| ME_add | mean error or bias of additive residuals |
4347
+------------+----------------------------------------------------------+
4448
| ME_mult | mean error or bias of multiplicative residuals |
@@ -111,8 +115,9 @@ def f(fct, obs, **kwargs):
111115
return f
112116

113117
# continuous
114-
elif name in ["beta", "corr_p", "corr_s", "me_add", "me_mult", "rmse_add",
115-
"rmse_mult", "rv_add", "rv_mult", "scatter"]:
118+
elif name in ["beta", "corr_p", "corr_s", "mae_add", "mae_mult",
119+
"me_add", "me_mult", "rmse_add", "rmse_mult", "rv_add",
120+
"rv_mult", "scatter"]:
116121
def f(fct, obs, **kwargs):
117122
return det_cont_fcst(fct, obs, [name], **kwargs)
118123
return f

0 commit comments

Comments
 (0)