diff options
author | Daniel Friesel <derf@finalrewind.org> | 2018-04-19 14:04:14 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2018-04-19 14:04:14 +0200 |
commit | 1a9cac2fd80baa377c4ca39e8626fb90a390ef8c (patch) | |
tree | 51c0f5a57fe424001594fc6b165742b4142fd3dc /lib/dfatool.py | |
parent | d103267330fe103be4cc8a19ab63f3cddaa1d217 (diff) |
set smape/mape to NaN if incalculable
Diffstat (limited to 'lib/dfatool.py')
-rwxr-xr-x | lib/dfatool.py | 4 |
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 |