From 1a9cac2fd80baa377c4ca39e8626fb90a390ef8c Mon Sep 17 00:00:00 2001
From: Daniel Friesel <derf@finalrewind.org>
Date: Thu, 19 Apr 2018 14:04:14 +0200
Subject: set smape/mape to NaN if incalculable

---
 lib/dfatool.py | 4 ++++
 1 file changed, 4 insertions(+)

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
 
-- 
cgit v1.2.3