File tree Expand file tree Collapse file tree 2 files changed +9
-6
lines changed
Expand file tree Collapse file tree 2 files changed +9
-6
lines changed Original file line number Diff line number Diff line change @@ -137,19 +137,19 @@ def commit(self):
137137 data_output = None
138138 self ._save_selected (actual = True )
139139
140+ data = self .data or self .classifier and self .classifier .instances
140141 if (self .selected is not None and
141- self . data is not None and
142+ data is not None and
142143 self .classifier is not None and
143- self . data .domain .attributes ==
144+ data .domain .attributes ==
144145 self .classifier .original_domain .attributes ):
145146
146- status = np .ones (self . data .X .shape [0 ], dtype = bool )
147+ status = np .ones (data .X .shape [0 ], dtype = bool )
147148 for i in self .selected :
148149 rule = self .classifier .rule_list [i ]
149- status &= rule .evaluate_data (self . data .X )
150+ status &= rule .evaluate_data (data .X )
150151
151- data_output = self .data .from_table_rows (
152- self .data , status .nonzero ()[0 ])
152+ data_output = data .from_table_rows (data , status .nonzero ()[0 ])
153153
154154 self .send (OWRuleViewer .data_output_identifier , data_output )
155155
Original file line number Diff line number Diff line change @@ -14,6 +14,9 @@ def setUp(self):
1414 self .titanic = Table ('titanic' )
1515 self .learner = CN2Learner ()
1616 self .classifier = self .learner (self .titanic )
17+ # CN2Learner does not add `instances` attribute to the model, but
18+ # the Rules widget does. We simulate the model we get from the widget.
19+ self .classifier .instances = self .titanic
1720 self .widget = self .create_widget (OWRuleViewer )
1821
1922 def test_set_data (self ):
You can’t perform that action at this time.
0 commit comments