Fix some excel issues

This commit is contained in:
2023-05-21 22:22:15 +02:00
parent 9041c412d5
commit 83bd321dd6
15 changed files with 145 additions and 105 deletions

View File

@@ -6,7 +6,7 @@ from types import SimpleNamespace
import xlsxwriter
from .Datasets import Datasets
from .ResultsBase import BaseReport, StubReport
from .ResultsBase import BaseReport, StubReport, get_input
from .ResultsFiles import Excel
from .Utils import NO_RESULTS, Files, Folders, TextColor

View File

@@ -3,7 +3,7 @@ from openpyxl import load_workbook
from xlsxwriter import Workbook
from .TestBase import TestBase
from ..ResultsFiles import Excel
from ..Utils import Folders
from ..Utils import Folders, Files
class ExcelTest(TestBase):
@@ -36,7 +36,7 @@ class ExcelTest(TestBase):
def test_Excel_Add_sheet(self):
file_name = "results_accuracy_STree_iMac27_2021-10-27_09:40:40_0.json"
excel_file_name = file_name.replace(".json", ".xlsx")
excel_file_name = file_name.replace(Files.report_ext, ".xlsx")
book = Workbook(os.path.join(Folders.excel, excel_file_name))
excel = Excel(file_name=file_name, book=book)
excel.report()

View File

@@ -31,6 +31,7 @@ class TestBase(unittest.TestCase):
os.remove(file_name)
def generate_excel_sheet(self, sheet, file_name):
file_name += self.ext
with open(os.path.join(self.test_files, file_name), "w") as f:
for row in range(1, sheet.max_row + 1):
for col in range(1, sheet.max_column + 1):

1
benchmark/tests/excel/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
#

View File

@@ -39,12 +39,14 @@ class BeListTest(TestBase):
stdout, stderr = self.execute_script("be_list", ["-m", "STree"])
self.assertEqual(stderr.getvalue(), "")
self.check_output_file(stdout, "be_list_report_excel")
book = load_workbook(os.path.join(Folders.excel, Files.be_list_excel))
sheet = book["STree"]
self.check_excel_sheet(sheet, "excel")
@patch(
"benchmark.Results.get_input", side_effect=iter(["e 2", "e 1", "q"])
"benchmark.Results.get_input",
side_effect=iter(["e 2", "e 1", "q"]),
)
def test_be_list_report_excel_twice(self, input_data):
stdout, stderr = self.execute_script("be_list", ["-m", "STree"])
@@ -65,9 +67,10 @@ class BeListTest(TestBase):
self.assertEqual(stdout.getvalue(), f"{NO_RESULTS}\n")
@patch(
"benchmark.Results.get_input", side_effect=iter(["d 0", "y", "", "q"])
"benchmark.Results.get_input",
side_effect=iter(["d 0", "y", "", "q"]),
)
# @patch("benchmark.Results.get_input", side_effect=iter(["q"]))
# @patch("benchmark.ResultsBase.get_input", side_effect=iter(["q"]))
def test_be_list_delete(self, input_data):
def copy_files(source_folder, target_folder, file_name):
source = os.path.join(source_folder, file_name)
@@ -91,7 +94,8 @@ class BeListTest(TestBase):
self.fail("test_be_list_delete() should not raise exception")
@patch(
"benchmark.Results.get_input", side_effect=iter(["h 0", "y", "", "q"])
"benchmark.Results.get_input",
side_effect=iter(["h 0", "y", "", "q"]),
)
def test_be_list_hide(self, input_data):
def swap_files(source_folder, target_folder, file_name):

View File

@@ -13,7 +13,6 @@ class BeReportTest(TestBase):
def tearDown(self) -> None:
files = [
"results_accuracy_ODTE_Galgo_2022-04-20_10:52:20_0.sql",
"results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.xlsx",
]
self.remove_files(files, Folders.results)
@@ -21,6 +20,10 @@ class BeReportTest(TestBase):
[Files.datasets_report_excel],
os.path.join(os.getcwd(), Folders.excel),
)
files = [
"results_accuracy_ODTE_Galgo_2022-04-20_10:52:20_0.sql",
]
self.remove_files(files, Folders.sql)
return super().tearDown()
def test_be_report(self):
@@ -37,7 +40,7 @@ class BeReportTest(TestBase):
self.assertEqual(stderr.getvalue(), "")
self.assertEqual(stdout.getvalue(), "unknown does not exists!\n")
def test_be_report_compare(self):
def test_be_report_compared(self):
file_name = "results_accuracy_STree_iMac27_2021-09-30_11:42:07_0.json"
stdout, stderr = self.execute_script(
"be_report", ["file", file_name, "-c"]
@@ -149,7 +152,7 @@ class BeReportTest(TestBase):
["file", file_name, "-x"],
)
file_name = os.path.join(
Folders.excel, file_name.replace(".json", ".xlsx")
Folders.excel, file_name.replace(Files.report_ext, ".xlsx")
)
book = load_workbook(file_name)
sheet = book["STree"]
@@ -164,7 +167,7 @@ class BeReportTest(TestBase):
["file", file_name, "-q"],
)
file_name = os.path.join(
Folders.results, file_name.replace(".json", ".sql")
Folders.sql, file_name.replace(Files.report_ext, ".sql")
)
self.check_file_file(file_name, "sql")
self.assertEqual(stderr.getvalue(), "")

1
benchmark/tests/sql/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
#

View File

@@ -14,7 +14,8 @@
Dataset Sampl. Feat. Cls Nodes Leaves Depth Score Time Hyperparameters
============================== ====== ===== === ======= ======= ======= =============== ================= ===============
balance-scale 625 4 3 18.78 9.88 5.90 0.970000±0.0020 0.233304±0.0481 {'max_features': 'auto', 'splitter': 'mutual'}
balloons 16 4 2 4.72 2.86 2.78 0.556667±0.2941 0.021352±0.0058 {'max_features': 'auto', 'splitter': 'mutual'}
balloons 16 4 2 4.72 2.86 2.78 0.556667±0.2941 0.021352±0.0058 {'max_features': 'auto', 'splitter': 'mutual'}
*************************************************************************************************************************
* ✗ Less than or equal to ZeroR...: 1 *
* accuracy compared to STree_default (liblinear-ovr) .: 0.0379 *
*************************************************************************************************************************

View File

@@ -3,12 +3,12 @@
3;1;" Score is accuracy"
3;2;" Execution time"
3;5;" 624.25 s"
3;7;" "
3;8;"Platform"
3;7;"Platform"
3;9;"iMac27"
3;10;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
3;11;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;5;" 0.17 h"
4;10;"Stratified: False"
4;11;"Stratified: False"
4;13;"Discretized: False"
6;1;"Dataset"
6;2;"Samples"
6;3;"Features"
@@ -17,10 +17,11 @@
6;6;"Leaves"
6;7;"Depth"
6;8;"Score"
6;9;"Score Std."
6;10;"Time"
6;11;"Time Std."
6;12;"Hyperparameters"
6;9;"Stat"
6;10;"Score Std."
6;11;"Time"
6;12;"Time Std."
6;13;"Hyperparameters"
7;1;"balance-scale"
7;2;"625"
7;3;"4"
@@ -29,10 +30,11 @@
7;6;"4"
7;7;"3"
7;8;"0.97056"
7;9;"0.0150468069702512"
7;10;"0.01404867172241211"
7;11;"0.002026269126958884"
7;12;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}"
7;9;" "
7;10;"0.0150468069702512"
7;11;"0.01404867172241211"
7;12;"0.002026269126958884"
7;13;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}"
8;1;"balloons"
8;2;"16"
8;3;"4"
@@ -41,8 +43,12 @@
8;6;"2"
8;7;"2"
8;8;"0.86"
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, 'multiclass_strategy': 'ovr'}"
10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0454"
8;9;""
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, 'multiclass_strategy': 'ovr'}"
11;2;"➶"
11;3;"1"
11;4;"Better than ZeroR + 10.0%"
13;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0454"

View File

@@ -3,12 +3,12 @@
3;1;" Score is accuracy"
3;2;" Execution time"
3;5;"3,395.01 s"
3;7;" "
3;8;"Platform"
3;7;"Platform"
3;9;"iMac27"
3;10;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
3;11;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;5;" 0.94 h"
4;10;"Stratified: False"
4;11;"Stratified: False"
4;13;"Discretized: False"
6;1;"Dataset"
6;2;"Samples"
6;3;"Features"
@@ -17,10 +17,11 @@
6;6;"Leaves"
6;7;"Depth"
6;8;"Score"
6;9;"Score Std."
6;10;"Time"
6;11;"Time Std."
6;12;"Hyperparameters"
6;9;"Stat"
6;10;"Score Std."
6;11;"Time"
6;12;"Time Std."
6;13;"Hyperparameters"
7;1;"balance-scale"
7;2;"625"
7;3;"4"
@@ -29,10 +30,11 @@
7;6;"5.9"
7;7;"5.9"
7;8;"0.98"
7;9;"0.001"
7;10;"0.2852065515518188"
7;11;"0.06031593282605064"
7;12;"{'splitter': 'best', 'max_features': 'auto'}"
7;9;" "
7;10;"0.001"
7;11;"0.2852065515518188"
7;12;"0.06031593282605064"
7;13;"{'splitter': 'best', 'max_features': 'auto'}"
8;1;"balloons"
8;2;"16"
8;3;"4"
@@ -41,8 +43,12 @@
8;6;"2.56"
8;7;"2.56"
8;8;"0.695"
8;9;"0.2756860130252853"
8;10;"0.02120100021362305"
8;11;"0.003526023309468471"
8;12;"{'splitter': 'best', 'max_features': 'auto'}"
10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0416"
8;9;""
8;10;"0.2756860130252853"
8;11;"0.02120100021362305"
8;12;"0.003526023309468471"
8;13;"{'splitter': 'best', 'max_features': 'auto'}"
11;2;"➶"
11;3;"1"
11;4;"Better than ZeroR + 10.0%"
13;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0416"

View File

@@ -3,12 +3,12 @@
3;1;" Score is accuracy"
3;2;" Execution time"
3;5;"22,591.47 s"
3;7;" "
3;8;"Platform"
3;7;"Platform"
3;9;"Galgo"
3;10;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
3;11;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;5;" 6.28 h"
4;10;"Stratified: False"
4;11;"Stratified: False"
4;13;"Discretized: False"
6;1;"Dataset"
6;2;"Samples"
6;3;"Features"
@@ -17,10 +17,11 @@
6;6;"Leaves"
6;7;"Depth"
6;8;"Score"
6;9;"Score Std."
6;10;"Time"
6;11;"Time Std."
6;12;"Hyperparameters"
6;9;"Stat"
6;10;"Score Std."
6;11;"Time"
6;12;"Time Std."
6;13;"Hyperparameters"
7;1;"balance-scale"
7;2;"625"
7;3;"4"
@@ -29,10 +30,11 @@
7;6;"4.180599999999999"
7;7;"3.536"
7;8;"0.96352"
7;9;"0.02494974148162661"
7;10;"0.3166321754455567"
7;11;"0.1991881389525559"
7;12;"{'base_estimator__C': 57, 'base_estimator__gamma': 0.1, 'base_estimator__kernel': 'rbf', 'base_estimator__multiclass_strategy': 'ovr', 'n_estimators': 100, 'n_jobs': -1}"
7;9;" "
7;10;"0.02494974148162661"
7;11;"0.3166321754455567"
7;12;"0.1991881389525559"
7;13;"{'base_estimator__C': 57, 'base_estimator__gamma': 0.1, 'base_estimator__kernel': 'rbf', 'base_estimator__multiclass_strategy': 'ovr', 'n_estimators': 100, 'n_jobs': -1}"
8;1;"balloons"
8;2;"16"
8;3;"4"
@@ -41,8 +43,12 @@
8;6;"1.9976"
8;7;"1.9976"
8;8;"0.785"
8;9;"0.2461311755051675"
8;10;"0.1156062078475952"
8;11;"0.0127842418285999"
8;12;"{'base_estimator__C': 5, 'base_estimator__gamma': 0.14, 'base_estimator__kernel': 'rbf', 'base_estimator__multiclass_strategy': 'ovr', 'n_estimators': 100, 'n_jobs': -1}"
10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0434"
8;9;""
8;10;"0.2461311755051675"
8;11;"0.1156062078475952"
8;12;"0.0127842418285999"
8;13;"{'base_estimator__C': 5, 'base_estimator__gamma': 0.14, 'base_estimator__kernel': 'rbf', 'base_estimator__multiclass_strategy': 'ovr', 'n_estimators': 100, 'n_jobs': -1}"
11;2;"➶"
11;3;"1"
11;4;"Better than ZeroR + 10.0%"
13;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0434"

View File

@@ -3,12 +3,12 @@
3;1;" Score is accuracy"
3;2;" Execution time"
3;5;"3,395.01 s"
3;7;" "
3;8;"Platform"
3;7;"Platform"
3;9;"iMac27"
3;10;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
3;11;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;5;" 0.94 h"
4;10;"Stratified: False"
4;11;"Stratified: False"
4;13;"Discretized: False"
6;1;"Dataset"
6;2;"Samples"
6;3;"Features"
@@ -17,9 +17,11 @@
6;6;"Leaves"
6;7;"Depth"
6;8;"Score"
6;9;"Score Std."
6;10;"Time"
6;11;"Time Std."
6;9;"Stat"
6;10;"Score Std."
6;11;"Time"
6;12;"Time Std."
6;13;"Hyperparameters"
7;1;"balance-scale"
7;2;"625"
7;3;"4"
@@ -28,9 +30,11 @@
7;6;"5.9"
7;7;"5.9"
7;8;"0.98"
7;9;"0.001"
7;10;"0.2852065515518188"
7;11;"0.06031593282605064"
7;9;" "
7;10;"0.001"
7;11;"0.2852065515518188"
7;12;"0.06031593282605064"
7;13;"{'splitter': 'best', 'max_features': 'auto'}"
8;1;"balloons"
8;2;"16"
8;3;"4"
@@ -39,8 +43,12 @@
8;6;"2.56"
8;7;"2.56"
8;8;"0.695"
8;9;"0.2756860130252853"
8;10;"0.02120100021362305"
8;11;"0.003526023309468471"
8;12;"{'splitter': 'best', 'max_features': 'auto'}"
10;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0416"
8;9;""
8;10;"0.2756860130252853"
8;11;"0.02120100021362305"
8;12;"0.003526023309468471"
8;13;"{'splitter': 'best', 'max_features': 'auto'}"
11;2;"➶"
11;3;"1"
11;4;"Better than ZeroR + 10.0%"
13;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0416"

View File

@@ -3,10 +3,12 @@
3;1;" Score is accuracy"
3;2;" Execution time"
3;5;" 624.25 s"
3;8;"Platform"
3;7;"Platform"
3;9;"iMac27"
3;10;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;10;"Stratified: False"
3;11;"Random seeds: [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]"
4;5;" 0.17 h"
4;11;"Stratified: False"
4;13;"Discretized: False"
6;1;"Dataset"
6;2;"Samples"
6;3;"Features"
@@ -21,32 +23,32 @@
6;12;"Time Std."
6;13;"Hyperparameters"
7;1;"balance-scale"
7;2;625
7;3;4
7;4;3
7;5;7
7;6;4
7;7;3
7;8;0.97056
7;2;"625"
7;3;"4"
7;4;"3"
7;5;"7"
7;6;"4"
7;7;"3"
7;8;"0.97056"
7;9;" "
7;10;0.0150468069702512
7;11;0.01404867172241211
7;12;0.002026269126958884
7;10;"0.0150468069702512"
7;11;"0.01404867172241211"
7;12;"0.002026269126958884"
7;13;"{'C': 10000, 'gamma': 0.1, 'kernel': 'rbf', 'max_iter': 10000, 'multiclass_strategy': 'ovr'}"
8;1;"balloons"
8;2;16
8;3;4
8;4;2
8;5;3
8;6;2
8;7;2
8;8;0.86
8;2;"16"
8;3;"4"
8;4;"2"
8;5;"3"
8;6;"2"
8;7;"2"
8;8;"0.86"
8;9;"✔"
8;10;0.2850146195080759
8;11;0.0008541679382324218
8;12;3.629469326417878e-05
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, 'multiclass_strategy': 'ovr'}"
11;2;"✔"
11;3;1
11;3;"1"
11;4;"Equal to best"
13;1;"** accuracy compared to STree_default (liblinear-ovr) .: 0.0454"

View File

@@ -9,7 +9,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, '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'}
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'}
*************************************************************************************************************************
* ➶ Better than ZeroR + 10.0%.....: 1 *
* accuracy compared to STree_default (liblinear-ovr) .: 0.0454 *
*************************************************************************************************************************

View File

@@ -11,6 +11,6 @@ Dataset Sampl. Feat. Cls Nodes Leaves Depth Score
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 *
* ✔ Equal to best.................: 1 *
* accuracy compared to STree_default (liblinear-ovr) .: 0.0454 *
*************************************************************************************************************************