summaryrefslogtreecommitdiff
path: root/lib/utils.py
diff options
context:
space:
mode:
authorBirte Kristina Friesel <birte.friesel@uos.de>2023-12-14 09:31:55 +0100
committerBirte Kristina Friesel <birte.friesel@uos.de>2023-12-14 09:31:55 +0100
commit3f18526e01e7e2320355d12aae331143f4441256 (patch)
tree349eac65f6af98ac093617d71e8dcdb7df5d1875 /lib/utils.py
parenta224eb21e30b7d11cc532e7f7bd344bf8900c5f9 (diff)
add median and 90/95/99th percentile absolute errors to metrics
Diffstat (limited to 'lib/utils.py')
-rw-r--r--lib/utils.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/utils.py b/lib/utils.py
index 390a198..e7cf968 100644
--- a/lib/utils.py
+++ b/lib/utils.py
@@ -673,6 +673,11 @@ def regression_measures(predicted: np.ndarray, actual: np.ndarray):
if all items in actual are non-zero (NaN otherwise)
smape -- Symmetric Mean Absolute Percentage Error,
if no 0,0-pairs are present in actual and predicted (NaN otherwise)
+ p50 -- Median Absolute Error (as in: the median of the list of absolute
+ prediction errors aka. 50th percentile error)
+ p90 -- 90th percentile absolute error
+ p95 -- 95th percentile absolute error
+ p99 -- 99th percentile absolute error
msd -- Mean Square Deviation
rmsd -- Root Mean Square Deviation
ssr -- Sum of Squared Residuals
@@ -687,8 +692,13 @@ def regression_measures(predicted: np.ndarray, actual: np.ndarray):
# mean = np.mean(actual)
if len(deviations) == 0:
return {}
+ p50, p90, p95, p99 = np.percentile(np.abs(deviations), (50, 90, 95, 99))
measures = {
"mae": np.mean(np.abs(deviations), dtype=np.float64),
+ "p50": p50,
+ "p90": p90,
+ "p95": p95,
+ "p99": p99,
"msd": np.mean(deviations**2, dtype=np.float64),
"rmsd": np.sqrt(np.mean(deviations**2), dtype=np.float64),
"ssr": np.sum(deviations**2, dtype=np.float64),