1. biolab
  2. Untitled project
  3. orange

Commits

Aleš Erjavec  committed 9cb115c

Prevent division by zero in NeuralNetworkLearner/Classifier.

(fixes #1356)

  • Participants
  • Parent commits b1a52b1
  • Branches default

Comments (0)

Files changed (1)

File Orange/classification/neural.py

View file
         mean = X.mean(axis=0)
         std = X.std(axis=0)
         if self.normalize:
-            X = (X - mean) / std
+            X -= mean
+            X[:, std > 0] /= std[std > 0]
 
         #converts multi-target or single-target classes to numpy
         if any(isinstance(var, Orange.feature.Continuous)
         input = np.array([[float(e) for e in example]])
 
         if self.normalize:
-            input = (input - self.mean) / self.std
+            input -= self.mean
+            input[:, self.std > 0] /= self.std[self.std > 0]
 
         # transform results from numpy
         results = self.nn.predict(input).tolist()[0]