From 358c1f386c127cc6a90c0629ff92c5c451489f5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Montan=CC=83ana?= Date: Tue, 26 Apr 2022 16:07:47 +0200 Subject: [PATCH] replace pairtest lose test --- benchmark/Results.py | 1 + benchmark/tests/PairCheck_test.py | 4 +++- benchmark/tests/Summary_test.py | 13 ++++++++++++- benchmark/tests/test_files/paircheck_lose.test | 6 +++--- benchmark/tests/test_files/summary_show_top.test | 7 +++++++ 5 files changed, 26 insertions(+), 5 deletions(-) create mode 100644 benchmark/tests/test_files/summary_show_top.test diff --git a/benchmark/Results.py b/benchmark/Results.py index a5c3958..17cac14 100644 --- a/benchmark/Results.py +++ b/benchmark/Results.py @@ -1252,6 +1252,7 @@ class PairCheck: self.score_b = report_b.score for result_a, result_b in zip(report_a.lines, report_b.lines): result = result_a["score"] - result_b["score"] + if result > 0: self.winners.append(result_a["dataset"]) elif result < 0: diff --git a/benchmark/tests/PairCheck_test.py b/benchmark/tests/PairCheck_test.py index ecb5869..f0db27f 100644 --- a/benchmark/tests/PairCheck_test.py +++ b/benchmark/tests/PairCheck_test.py @@ -41,7 +41,9 @@ class PairCheckTest(unittest.TestCase): self.assertEqual(computed, expected) def test_pair_check_lose(self): - report = self.build_model(lose=True) + report = self.build_model( + model1="RandomForest", model2="STree", lose=True + ) report.compute() with patch("sys.stdout", new=StringIO()) as fake_out: report.report() diff --git a/benchmark/tests/Summary_test.py b/benchmark/tests/Summary_test.py index fcfb168..77e4a18 100644 --- a/benchmark/tests/Summary_test.py +++ b/benchmark/tests/Summary_test.py @@ -3,7 +3,6 @@ import unittest from io import StringIO from unittest.mock import patch from ..Results import Summary -from ..Utils import Symbols class SummaryTest(unittest.TestCase): @@ -232,3 +231,15 @@ class SummaryTest(unittest.TestCase): ), } self.assertSequenceEqual(computed, expected) + + def test_show_top(self): + report = Summary() + report.acquire() + with patch("sys.stdout", new=StringIO()) as fake_out: + report.show_top() + computed = fake_out.getvalue() + with open( + os.path.join("test_files", "summary_show_top.test"), "r" + ) as f: + expected = f.read() + self.assertEqual(computed, expected) diff --git a/benchmark/tests/test_files/paircheck_lose.test b/benchmark/tests/test_files/paircheck_lose.test index c1b3174..415ec0d 100644 --- a/benchmark/tests/test_files/paircheck_lose.test +++ b/benchmark/tests/test_files/paircheck_lose.test @@ -1,6 +1,6 @@ Model File Score Win Tie Lose ==================== ====================================================================== ========== === === ==== -STree results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json 0.04544 -RandomForest results_accuracy_RandomForest_iMac27_2022-01-14_12:39:30_0.json 0.03627  2  0  0 +RandomForest results_accuracy_RandomForest_iMac27_2022-01-14_12:39:30_0.json 0.03627 +STree results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json 0.04544  0  0  2 losers: -[] +['balance-scale', 'balloons'] diff --git a/benchmark/tests/test_files/summary_show_top.test b/benchmark/tests/test_files/summary_show_top.test new file mode 100644 index 0000000..7dc47f9 --- /dev/null +++ b/benchmark/tests/test_files/summary_show_top.test @@ -0,0 +1,7 @@ +Date File Score Time(h) Title +========== =============================================================== ======== ======= ============================================ +2021-09-30 results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json 0.04544 0.173 With gridsearched hyperparameters +2022-04-20 results_accuracy_ODTE_Galgo_2022-04-20_10:52:20_0.json 0.04341 6.275 Gridsearched hyperparams v022.1b random_init +2021-10-27 results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json 0.04158 0.943 default A +2021-11-01 results_accuracy_STree_macbook-pro_2021-11-01_19:17:07_0.json 0.03790 1.143 default B +2022-01-14 results_accuracy_RandomForest_iMac27_2022-01-14_12:39:30_0.json 0.03627 0.076 Test default paramters with RandomForest