Skip to content

Commit

Permalink
Merge pull request #2392 from jerneju/value-logisticregression
Browse files Browse the repository at this point in the history
[FIX] Logistic Regression: impute
  • Loading branch information
lanzagar authored Jun 24, 2017
2 parents e426359 + 42bafb1 commit 942877a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Orange/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ def __call__(self, data):

self.domain = data.domain
model = self._fit_model(data)
model.used_vals = [np.unique(y) for y in data.Y[:, None].T]
model.domain = data.domain
model.supports_multiclass = self.supports_multiclass
model.name = self.name
Expand Down Expand Up @@ -377,7 +378,6 @@ def preprocess(self, data):

def __call__(self, data):
m = super().__call__(data)
m.used_vals = [np.unique(y) for y in data.Y[:, None].T]
m.params = self.params
return m

Expand Down
16 changes: 16 additions & 0 deletions Orange/widgets/model/tests/test_owlogisticregression.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# pylint: disable=missing-docstring
import unittest

import numpy as np

from Orange.classification import LogisticRegressionLearner
from Orange.data import Table, Domain, ContinuousVariable, DiscreteVariable
from Orange.statistics.util import stats
Expand Down Expand Up @@ -95,3 +97,17 @@ def test_coefficients_one_value(self):
coef = self.get_output("Coefficients")
self.assertEqual(coef.domain[0].name, "no")
self.assertGreater(coef[2][0], 0.)

def test_target_with_nan(self):
"""
Rows with targets with nans are removed.
GH-2392
"""
table = Table("iris")
table.Y[5:10] = np.NaN
self.send_signal("Data", table)
coef1 = self.get_output("Coefficients")
del table[5:10]
self.send_signal("Data", table)
coef2 = self.get_output("Coefficients")
self.assertTrue(np.array_equal(coef1, coef2))

0 comments on commit 942877a

Please sign in to comment.