Added a few metrics for measuring performance

This commit is contained in:
dario
2023-12-14 23:29:58 +01:00
parent 33e5eba3a6
commit 4a93fd4ee6
5 changed files with 49 additions and 7 deletions

20
spatz/metrics/max_dev.py Normal file
View File

@@ -0,0 +1,20 @@
from numpy.typing import ArrayLike
from spatz.metrics import Metric
class MaxAbsDeviation(Metric):
def __init__(self) -> None:
"""A metric tracking the maximum absolute deviation from the true value."""
super().__init__()
def _update(self, x: ArrayLike, y: ArrayLike):
self._score = max(self._score, abs(x - y))
class MaxRelDeviation(Metric):
def __init__(self) -> None:
"""A metric tracking the maximum deviation from the true value in percent."""
super().__init__()
def _update(self, x: ArrayLike, y: ArrayLike):
self._score = max(self._score, (x - y) / y)