|
7 | 7 | from Orange.data.io import TabReader |
8 | 8 | from Orange.widgets.tests.base import WidgetTest |
9 | 9 | from Orange.widgets.evaluate.owpredictions import OWPredictions |
| 10 | +from Orange.widgets.evaluate.owcalibrationplot import OWCalibrationPlot |
| 11 | +from Orange.widgets.evaluate.owconfusionmatrix import OWConfusionMatrix |
| 12 | +from Orange.widgets.evaluate.owliftcurve import OWLiftCurve |
| 13 | +from Orange.widgets.evaluate.owrocanalysis import OWROCAnalysis |
10 | 14 |
|
11 | | -from Orange.data import Table, Domain |
| 15 | +from Orange.data import Table, Domain, DiscreteVariable |
12 | 16 | from Orange.modelling import ConstantLearner, TreeLearner |
13 | 17 | from Orange.evaluation import Results |
14 | 18 | from Orange.widgets.tests.utils import excepthook_catch |
@@ -49,6 +53,38 @@ def test_nan_target_input(self): |
49 | 53 | evres = self.get_output(self.widget.Outputs.evaluation_results) |
50 | 54 | self.assertEqual(len(evres.data), 0) |
51 | 55 |
|
| 56 | + def test_no_values_target(self): |
| 57 | + train = Table("titanic") |
| 58 | + model = ConstantLearner()(train) |
| 59 | + self.send_signal(self.widget.Inputs.predictors, model) |
| 60 | + domain = Domain([DiscreteVariable("status", values=["first", "third"]), |
| 61 | + DiscreteVariable("age", values=["adult", "child"]), |
| 62 | + DiscreteVariable("sex", values=["female", "male"])], |
| 63 | + [DiscreteVariable("survived", values=[])]) |
| 64 | + test = Table(domain, np.array([[0, 0, 1], [0, 1, 0], [1, 0, 0]]), |
| 65 | + np.full((3, 1), np.nan)) |
| 66 | + self.send_signal(self.widget.Inputs.data, test) |
| 67 | + pred = self.get_output(self.widget.Outputs.predictions) |
| 68 | + self.assertEqual(len(pred), len(test)) |
| 69 | + |
| 70 | + results = self.get_output(self.widget.Outputs.evaluation_results) |
| 71 | + |
| 72 | + cm_widget = self.create_widget(OWConfusionMatrix) |
| 73 | + self.send_signal(cm_widget.Inputs.evaluation_results, results, |
| 74 | + widget=cm_widget) |
| 75 | + |
| 76 | + ra_widget = self.create_widget(OWROCAnalysis) |
| 77 | + self.send_signal(ra_widget.Inputs.evaluation_results, results, |
| 78 | + widget=ra_widget) |
| 79 | + |
| 80 | + lc_widget = self.create_widget(OWLiftCurve) |
| 81 | + self.send_signal(lc_widget.Inputs.evaluation_results, results, |
| 82 | + widget=lc_widget) |
| 83 | + |
| 84 | + cp_widget = self.create_widget(OWCalibrationPlot) |
| 85 | + self.send_signal(cp_widget.Inputs.evaluation_results, results, |
| 86 | + widget=cp_widget) |
| 87 | + |
52 | 88 | def test_mismatching_targets(self): |
53 | 89 | warning = self.widget.Warning |
54 | 90 |
|
|
0 commit comments