summaryrefslogtreecommitdiff
path: root/lib/dfatool.py
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2018-04-19 14:04:14 +0200
committerDaniel Friesel <derf@finalrewind.org>2018-04-19 14:04:14 +0200
commit1a9cac2fd80baa377c4ca39e8626fb90a390ef8c (patch)
tree51c0f5a57fe424001594fc6b165742b4142fd3dc /lib/dfatool.py
parentd103267330fe103be4cc8a19ab63f3cddaa1d217 (diff)
set smape/mape to NaN if incalculable
Diffstat (limited to 'lib/dfatool.py')
-rwxr-xr-xlib/dfatool.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py
index f0f71f1..299190f 100755
--- a/lib/dfatool.py
+++ b/lib/dfatool.py
@@ -135,8 +135,12 @@ def regression_measures(predicted, actual):
if np.all(actual != 0):
measures['mape'] = np.mean(np.abs(deviations / actual)) * 100 # bad measure
+ else:
+ measures['mape'] = np.nan
if np.all(np.abs(predicted) + np.abs(actual) != 0):
measures['smape'] = np.mean(np.abs(deviations) / (( np.abs(predicted) + np.abs(actual)) / 2 )) * 100
+ else:
+ measures['smape'] = np.nan
#if np.all(rsq_quotient != 0):
# measures['rsq'] = (np.sum((actual - mean) * (predicted - mean), dtype=np.float64)**2) / rsq_quotient