From 6dc3a59df825c7624cb2a9ecff5c4307aaa6ab24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ricardo=20Monta=C3=B1ana=20G=C3=B3mez?= Date: Sat, 14 Jan 2023 21:31:34 +0100 Subject: [PATCH] fix: :test_tube: Fix tests with new scikit-learn version --- benchmark/scripts/be_build_grid.py | 5 ++-- benchmark/tests/BestResults_test.py | 2 +- benchmark/tests/Experiment_test.py | 2 +- .../results/best_results_accuracy_STree.json | 2 +- ...cy_STree_iMac27_2021-09-30_11:42:07_0.json | 6 ++-- benchmark/tests/test_files/be_build_grid.test | 28 +++++++++---------- benchmark/tests/test_files/be_main_best.test | 2 +- benchmark/tests/test_files/excel.test | 4 +-- .../tests/test_files/excel_compared.test | 4 +-- .../test_files/exreport_excel_STree.test | 4 +-- benchmark/tests/test_files/report.test | 4 +-- benchmark/tests/test_files/report_best.test | 2 +- .../tests/test_files/report_compared.test | 4 +-- 13 files changed, 35 insertions(+), 34 deletions(-) diff --git a/benchmark/scripts/be_build_grid.py b/benchmark/scripts/be_build_grid.py index d4ea653..5dd5bb7 100755 --- a/benchmark/scripts/be_build_grid.py +++ b/benchmark/scripts/be_build_grid.py @@ -46,7 +46,7 @@ def main(args_test=None): '{"C": 7, "gamma": 0.1, "kernel": "rbf", "multiclass_strategy": ' '"ovr"}', '{"C": 5, "kernel": "rbf", "gamma": "auto"}', - '{"C": 0.05, "max_iter": 10000.0, "kernel": "liblinear", ' + '{"C": 0.05, "max_iter": 10000, "kernel": "liblinear", ' '"multiclass_strategy": "ovr"}', '{"C":0.0275, "kernel": "liblinear", "multiclass_strategy": "ovr"}', '{"C": 7, "gamma": 10.0, "kernel": "rbf", "multiclass_strategy": ' @@ -97,7 +97,7 @@ def main(args_test=None): for item in results: results_tmp = {"n_jobs": [-1], "n_estimators": [100]} for key, value in results[item].items(): - new_key = f"base_estimator__{key}" + new_key = f"estimator__{key}" try: results_tmp[new_key] = sorted(value) except TypeError: @@ -111,6 +111,7 @@ def main(args_test=None): t2 = sorted([x for x in value if isinstance(x, str)]) results_tmp[new_key] = t1 + t2 output.append(results_tmp) + # save results file_name = Files.grid_input(args.score, args.model) file_output = os.path.join(Folders.results, file_name) diff --git a/benchmark/tests/BestResults_test.py b/benchmark/tests/BestResults_test.py index 76a5ea8..f4df24b 100644 --- a/benchmark/tests/BestResults_test.py +++ b/benchmark/tests/BestResults_test.py @@ -18,7 +18,7 @@ class BestResultTest(TestBase): "C": 7, "gamma": 0.1, "kernel": "rbf", - "max_iter": 10000.0, + "max_iter": 10000, "multiclass_strategy": "ovr", }, "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json", diff --git a/benchmark/tests/Experiment_test.py b/benchmark/tests/Experiment_test.py index 7ef9ff7..4ac6b24 100644 --- a/benchmark/tests/Experiment_test.py +++ b/benchmark/tests/Experiment_test.py @@ -52,7 +52,7 @@ class ExperimentTest(TestBase): "C": 7, "gamma": 0.1, "kernel": "rbf", - "max_iter": 10000.0, + "max_iter": 10000, "multiclass_strategy": "ovr", }, "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json", diff --git a/benchmark/tests/results/best_results_accuracy_STree.json b/benchmark/tests/results/best_results_accuracy_STree.json index 1cbd82e..4a4ee75 100644 --- a/benchmark/tests/results/best_results_accuracy_STree.json +++ b/benchmark/tests/results/best_results_accuracy_STree.json @@ -1 +1 @@ -{"balance-scale": [0.98, {"splitter": "best", "max_features": "auto"}, "results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json"], "balloons": [0.86, {"C": 7, "gamma": 0.1, "kernel": "rbf", "max_iter": 10000.0, "multiclass_strategy": "ovr"}, "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json"]} \ No newline at end of file +{"balance-scale": [0.98, {"splitter": "best", "max_features": "auto"}, "results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json"], "balloons": [0.86, {"C": 7, "gamma": 0.1, "kernel": "rbf", "max_iter": 10000, "multiclass_strategy": "ovr"}, "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json"]} \ No newline at end of file diff --git a/benchmark/tests/results/results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json b/benchmark/tests/results/results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json index 197b1f6..4988acf 100644 --- a/benchmark/tests/results/results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json +++ b/benchmark/tests/results/results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json @@ -17,10 +17,10 @@ "features": 4, "classes": 3, "hyperparameters": { - "C": 10000.0, + "C": 10000, "gamma": 0.1, "kernel": "rbf", - "max_iter": 10000.0, + "max_iter": 10000, "multiclass_strategy": "ovr" }, "nodes": 7.0, @@ -40,7 +40,7 @@ "C": 7, "gamma": 0.1, "kernel": "rbf", - "max_iter": 10000.0, + "max_iter": 10000, "multiclass_strategy": "ovr" }, "nodes": 3.0, diff --git a/benchmark/tests/test_files/be_build_grid.test b/benchmark/tests/test_files/be_build_grid.test index 332abc1..f3549e2 100644 --- a/benchmark/tests/test_files/be_build_grid.test +++ b/benchmark/tests/test_files/be_build_grid.test @@ -6,13 +6,13 @@ "n_estimators": [ 100 ], - "base_estimator__C": [ + "estimator__C": [ 1.0 ], - "base_estimator__kernel": [ + "estimator__kernel": [ "linear" ], - "base_estimator__multiclass_strategy": [ + "estimator__multiclass_strategy": [ "ovo" ] }, @@ -23,7 +23,7 @@ "n_estimators": [ 100 ], - "base_estimator__C": [ + "estimator__C": [ 0.001, 0.0275, 0.05, @@ -36,10 +36,10 @@ 7, 10000.0 ], - "base_estimator__kernel": [ + "estimator__kernel": [ "liblinear" ], - "base_estimator__multiclass_strategy": [ + "estimator__multiclass_strategy": [ "ovr" ] }, @@ -50,7 +50,7 @@ "n_estimators": [ 100 ], - "base_estimator__C": [ + "estimator__C": [ 0.05, 1.0, 1.05, @@ -62,7 +62,7 @@ 57, 10000.0 ], - "base_estimator__gamma": [ + "estimator__gamma": [ 0.001, 0.1, 0.14, @@ -70,10 +70,10 @@ "auto", "scale" ], - "base_estimator__kernel": [ + "estimator__kernel": [ "rbf" ], - "base_estimator__multiclass_strategy": [ + "estimator__multiclass_strategy": [ "ovr" ] }, @@ -84,20 +84,20 @@ "n_estimators": [ 100 ], - "base_estimator__C": [ + "estimator__C": [ 0.05, 0.2, 1.0, 8.25 ], - "base_estimator__gamma": [ + "estimator__gamma": [ 0.1, "scale" ], - "base_estimator__kernel": [ + "estimator__kernel": [ "poly" ], - "base_estimator__multiclass_strategy": [ + "estimator__multiclass_strategy": [ "ovo", "ovr" ] diff --git a/benchmark/tests/test_files/be_main_best.test b/benchmark/tests/test_files/be_main_best.test index a18372b..a694c57 100644 --- a/benchmark/tests/test_files/be_main_best.test +++ b/benchmark/tests/test_files/be_main_best.test @@ -9,7 +9,7 @@ Dataset Sampl. Feat. Cls Nodes Leaves Depth Score Time Hyperparameters ============================== ====== ===== === ======= ======= ======= =============== ================= =============== balance-scale 625 4 3 23.32 12.16 6.44 0.840160±0.0304 0.013745±0.0019 {'splitter': 'best', 'max_features': 'auto'} -balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850 0.000388±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} +balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850 0.000388±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} ************************************************************************************************************************* * accuracy compared to STree_default (liblinear-ovr) .: 0.0422 * ************************************************************************************************************************* diff --git a/benchmark/tests/test_files/excel.test b/benchmark/tests/test_files/excel.test index dbb9675..33e813f 100644 --- a/benchmark/tests/test_files/excel.test +++ b/benchmark/tests/test_files/excel.test @@ -32,7 +32,7 @@ 7;9;"0.0150468069702512" 7;10;"0.01404867172241211" 7;11;"0.002026269126958884" -7;12;"{'C': 10000.0, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +7;12;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 8;1;"balloons" 8;2;"16" 8;3;"4" @@ -44,5 +44,5 @@ 8;9;"0.2850146195080759" 8;10;"0.0008541679382324218" 8;11;"3.629469326417878e-05" -8;12;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +8;12;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0454" \ No newline at end of file diff --git a/benchmark/tests/test_files/excel_compared.test b/benchmark/tests/test_files/excel_compared.test index 2b44c1e..92b678d 100644 --- a/benchmark/tests/test_files/excel_compared.test +++ b/benchmark/tests/test_files/excel_compared.test @@ -32,7 +32,7 @@ 7;10;0.0150468069702512 7;11;0.01404867172241211 7;12;0.002026269126958884 -7;13;"{'C': 10000.0, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +7;13;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 8;1;"balloons" 8;2;16 8;3;4 @@ -45,7 +45,7 @@ 8;10;0.2850146195080759 8;11;0.0008541679382324218 8;12;3.629469326417878e-05 -8;13;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +8;13;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 11;2;"✔" 11;3;1 11;4;"Equal to best" diff --git a/benchmark/tests/test_files/exreport_excel_STree.test b/benchmark/tests/test_files/exreport_excel_STree.test index 6a164b5..dd1728a 100644 --- a/benchmark/tests/test_files/exreport_excel_STree.test +++ b/benchmark/tests/test_files/exreport_excel_STree.test @@ -32,7 +32,7 @@ 7;9;"0.0150468069702512" 7;10;"0.01404867172241211" 7;11;"0.002026269126958884" -7;12;"{'C': 10000.0, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +7;12;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 8;1;"balloons" 8;2;"16" 8;3;"4" @@ -44,5 +44,5 @@ 8;9;"0.2850146195080759" 8;10;"0.0008541679382324218" 8;11;"3.629469326417878e-05" -8;12;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'}" +8;12;"{'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}" 10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0454" diff --git a/benchmark/tests/test_files/report.test b/benchmark/tests/test_files/report.test index 0e5ffa9..c4b783f 100644 --- a/benchmark/tests/test_files/report.test +++ b/benchmark/tests/test_files/report.test @@ -8,8 +8,8 @@ Dataset Sampl. Feat. Cls Nodes Leaves Depth Score Time Hyperparameters ============================== ====== ===== === ======= ======= ======= =============== ================= =============== -balance-scale 625 4 3 7.00 4.00 3.00 0.970560±0.0150 0.014049±0.0020 {'C': 10000.0, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} -balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850 0.000854±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} +balance-scale 625 4 3 7.00 4.00 3.00 0.970560±0.0150 0.014049±0.0020 {'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} +balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850 0.000854±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} ************************************************************************************************************************* * accuracy compared to STree_default (liblinear-ovr) .: 0.0454 * ************************************************************************************************************************* diff --git a/benchmark/tests/test_files/report_best.test b/benchmark/tests/test_files/report_best.test index 03ffc30..77beb05 100644 --- a/benchmark/tests/test_files/report_best.test +++ b/benchmark/tests/test_files/report_best.test @@ -5,7 +5,7 @@ Dataset Score File/Message Hyperparameters ============================== ======== ============================================================================ ============================================= balance-scale 0.980000 results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json {'splitter': 'best', 'max_features': 'auto'} -balloons 0.860000 results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} +balloons 0.860000 results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} ****************************************************************************************************************************************************************** * accuracy compared to STree_default (liblinear-ovr) .: 0.0457 * ****************************************************************************************************************************************************************** diff --git a/benchmark/tests/test_files/report_compared.test b/benchmark/tests/test_files/report_compared.test index 103fb5d..6229759 100644 --- a/benchmark/tests/test_files/report_compared.test +++ b/benchmark/tests/test_files/report_compared.test @@ -8,8 +8,8 @@ Dataset Sampl. Feat. Cls Nodes Leaves Depth Score Time Hyperparameters ============================== ====== ===== === ======= ======= ======= =============== ================= =============== -balance-scale 625 4 3 7.00 4.00 3.00 0.970560±0.0150 0.014049±0.0020 {'C': 10000.0, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} -balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850✔ 0.000854±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000.0, 'multiclass_strategy': 'ovr'} +balance-scale 625 4 3 7.00 4.00 3.00 0.970560±0.0150 0.014049±0.0020 {'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} +balloons 16 4 2 3.00 2.00 2.00 0.860000±0.2850✔ 0.000854±0.0000 {'C': 7, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'} ************************************************************************************************************************* * ✔ Equal to best .....: 1 * * accuracy compared to STree_default (liblinear-ovr) .: 0.0454 *