Skip to content

Commit

Permalink
Confusion matrix widget: Add tests for selected_learner
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Aug 26, 2016
1 parent 8a492d7 commit 3aea927
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
1 change: 0 additions & 1 deletion Orange/widgets/evaluate/owconfusionmatrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ def set_results(self, results):

self._init_table(len(class_values))
self.openContext(data.domain.class_var)
print("ZZZ", prev_sel_learner)
if not prev_sel_learner or prev_sel_learner[0] >= len(self.learners):
self.selected_learner[:] = [0]
else:
Expand Down
Empty file.
44 changes: 44 additions & 0 deletions Orange/widgets/evaluate/tests/test_owconfusionmatrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import unittest
import ast
import sys

from Orange.data import Table
from Orange.classification import NaiveBayesLearner, TreeLearner
from Orange.evaluation.testing import CrossValidation
from Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix
from Orange.widgets.tests.base import WidgetTest, WidgetLearnerTestMixin


class TestOWClassificationTree(WidgetTest):
@classmethod
def setUpClass(cls):
super().setUpClass()
bayes = NaiveBayesLearner()
tree = TreeLearner()
iris = Table("iris")
titanic = Table("titanic")
common = dict(k=3, store_data=True)
cls.results_1_iris = CrossValidation(iris, [bayes], **common)
cls.results_2_iris = CrossValidation(iris, [bayes, tree], **common)
cls.results_2_titanic = CrossValidation(titanic, [bayes, tree],
**common)

def setUp(self):
self.widget = self.create_widget(OWConfusionMatrix,
stored_settings={"auto_apply": False})

def test_selected_learner(self):
"""Check learner and model for various values of all parameters
when pruning parameters are not checked
"""
self.widget.set_results(self.results_2_iris)
self.assertEqual(self.widget.selected_learner, [0])
self.widget.selected_learner[:] = [1]
self.widget.set_results(self.results_2_titanic)
self.widget.selected_learner[:] = [1]
self.widget.set_results(self.results_1_iris)
self.widget.selected_learner[:] = [0]
self.widget.set_results(None)
self.widget.set_results(self.results_1_iris)
self.widget.selected_learner[:] = [0]

0 comments on commit 3aea927

Please sign in to comment.