From 8dc10a7ef46207a1601d2495ab52e3acb8066d37 Mon Sep 17 00:00:00 2001
From: Nikolai Hartmann <Nikolai.Hartmann@physik.uni-muenchen.de>
Date: Tue, 7 Aug 2018 16:30:25 +0200
Subject: [PATCH] handle zero scales for WeightedRobustScaler

---
 utils.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/utils.py b/utils.py
index adf213f..1da306c 100644
--- a/utils.py
+++ b/utils.py
@@ -6,6 +6,7 @@ import numpy as np
 
 import keras.backend as K
 from sklearn.preprocessing import RobustScaler
+from sklearn.preprocessing.data import _handle_zeros_in_scale
 
 from meme import cache
 
@@ -140,5 +141,6 @@ class WeightedRobustScaler(RobustScaler):
             wqs = np.array([weighted_quantile(X[:,i], [0.25, 0.5, 0.75], sample_weight=weights) for i in range(X.shape[1])])
             self.center_ = wqs[:,1]
             self.scale_ = wqs[:,2]-wqs[:,0]
+            self.scale_ = _handle_zeros_in_scale(self.scale_, copy=False)
             return self
 
-- 
GitLab