From 3204e426668de974f2e7d151255401dd78d69059 Mon Sep 17 00:00:00 2001 From: Andreja Kovacic Date: Fri, 17 Jan 2020 11:39:36 +0100 Subject: [PATCH] Clip minimum to 0 --- Orange/distance/distance.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Orange/distance/distance.py b/Orange/distance/distance.py index 246d9e80037..aca1679d4a8 100644 --- a/Orange/distance/distance.py +++ b/Orange/distance/distance.py @@ -749,9 +749,9 @@ def _bhattacharyya(a, b): check_non_negative(b) a = _prob_dist(a) b = _prob_dist(b) - if sp.issparse(a): - return -np.log(np.sum(np.sqrt(a.multiply(b)))) - return -np.log(np.sum(np.sqrt(a * b))) + prod = a.multiply(b) if sp.issparse(a) else a * b + return np.clip(-np.log(np.sum(np.sqrt(prod))), 0, None) + class Bhattacharyya(Distance):