From cb6e1790f33d4e9f9a93f6e69985438f6954f579 Mon Sep 17 00:00:00 2001 From: Jernej Urankar Date: Fri, 9 Jun 2017 13:50:54 +0200 Subject: [PATCH 1/2] [FIX] ROC Analysis: color support for more than 9 evaluation learners https://sentry.io/biolab/orange3/issues/210623933/ --- Orange/widgets/evaluate/owrocanalysis.py | 3 +-- .../evaluate/tests/test_owrocanalysis.py | 23 ++++++++++++++++++- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/Orange/widgets/evaluate/owrocanalysis.py b/Orange/widgets/evaluate/owrocanalysis.py index ebcb2f23699..056cf5bc3ce 100644 --- a/Orange/widgets/evaluate/owrocanalysis.py +++ b/Orange/widgets/evaluate/owrocanalysis.py @@ -448,8 +448,7 @@ def _initialize(self, results): names = ["#{}".format(i + 1) for i in range(len(results.predicted))] - self.colors = colorpalette.ColorPaletteGenerator( - len(names), colorbrewer.colorSchemes["qualitative"]["Dark2"]) + self.colors = colorpalette.ColorPaletteGenerator(len(names)) self.classifier_names = names self.selected_classifiers = list(range(len(names))) diff --git a/Orange/widgets/evaluate/tests/test_owrocanalysis.py b/Orange/widgets/evaluate/tests/test_owrocanalysis.py index 3d09c879ba2..12378d54bfa 100644 --- a/Orange/widgets/evaluate/tests/test_owrocanalysis.py +++ b/Orange/widgets/evaluate/tests/test_owrocanalysis.py @@ -152,4 +152,25 @@ def test_nan_input(self): self.send_signal("Evaluation Results", res) self.assertTrue(self.widget.Error.invalid_results.is_shown()) self.send_signal("Evaluation Results", None) - self.assertFalse(self.widget.Error.invalid_results.is_shown()) \ No newline at end of file + self.assertFalse(self.widget.Error.invalid_results.is_shown()) + + def test_many_evaluation_results(self): + """ + Now works with more than 9 evaluation results. + GH-2394 + """ + data = Orange.data.Table("iris") + learners = [ + Orange.classification.MajorityLearner(), + Orange.classification.LogisticRegressionLearner(), + Orange.classification.TreeLearner(), + Orange.classification.SVMLearner(), + Orange.classification.KNNLearner(), + Orange.classification.CN2Learner(), + Orange.classification.SGDClassificationLearner(), + Orange.classification.RandomForestLearner(), + Orange.classification.NaiveBayesLearner(), + Orange.classification.SGDClassificationLearner() + ] + res = Orange.evaluation.CrossValidation(data, learners, k=2, store_data=True) + self.send_signal("Evaluation Results", res) From 06de5b54b8cf345677f1ad71880f61356bc2c91c Mon Sep 17 00:00:00 2001 From: janezd Date: Fri, 16 Jun 2017 17:01:19 +0200 Subject: [PATCH 2/2] ROC Analysis: Reenable the original palette when possible --- Orange/widgets/evaluate/owrocanalysis.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Orange/widgets/evaluate/owrocanalysis.py b/Orange/widgets/evaluate/owrocanalysis.py index 056cf5bc3ce..8c628487391 100644 --- a/Orange/widgets/evaluate/owrocanalysis.py +++ b/Orange/widgets/evaluate/owrocanalysis.py @@ -448,7 +448,10 @@ def _initialize(self, results): names = ["#{}".format(i + 1) for i in range(len(results.predicted))] - self.colors = colorpalette.ColorPaletteGenerator(len(names)) + scheme = colorbrewer.colorSchemes["qualitative"]["Dark2"] + if len(names) > len(scheme): + scheme = colorpalette.DefaultRGBColors + self.colors = colorpalette.ColorPaletteGenerator(len(names), scheme) self.classifier_names = names self.selected_classifiers = list(range(len(names)))