Skip to content

Commit

Permalink
Merge pull request #5828 from lanzagar/fix_lda
Browse files Browse the repository at this point in the history
[FIX] Linear Projection: Fix LDA
  • Loading branch information
VesnaT authored Feb 11, 2022
2 parents 5a57006 + 1bf5e7e commit b0fbaa1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Orange/widgets/visualize/owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,10 @@ def effective_variables(self):

@property
def effective_data(self):
return self.data.transform(Domain(self.effective_variables))
cvs = None
if self.placement == Placement.LDA:
cvs = self.data.domain.class_vars
return self.data.transform(Domain(self.effective_variables, cvs))

def __vizrank_set_attrs(self, attrs):
if not attrs:
Expand Down
2 changes: 2 additions & 0 deletions Orange/widgets/visualize/tests/test_owlinearprojection.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ def test_no_data_for_lda(self):
self.send_signal(self.widget.Inputs.data, self.data)
self.widget.radio_placement.buttons[Placement.LDA].click()
self.assertTrue(buttons[Placement.LDA].isEnabled())
output = self.get_output(self.widget.Outputs.components)
self.assertTrue(output and len(output) == 2)
self.send_signal(self.widget.Inputs.data, Table("housing"))
self.assertFalse(buttons[Placement.LDA].isEnabled())
self.send_signal(self.widget.Inputs.data, None)
Expand Down
5 changes: 4 additions & 1 deletion Orange/widgets/visualize/utils/widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ def set_data(self, data):
self.openContext(self.data)
self._invalidated = not (
data_existed and self.data is not None and
array_equal(effective_data.X, self.effective_data.X))
array_equal(effective_data.X, self.effective_data.X) and
array_equal(effective_data.Y, self.effective_data.Y) and
array_equal(effective_data.metas, self.effective_data.metas)
)
self._domain_invalidated = not (
data_existed and self.data is not None and
effective_data.domain.checksum()
Expand Down

0 comments on commit b0fbaa1

Please sign in to comment.