mirror of
https://github.com/Doctorado-ML/Stree_datasets.git
synced 2025-08-16 07:56:07 +00:00
add csv output to analysis_mysql 4 Friedman test
add j48_svm to analysis_mysql
This commit is contained in:
@@ -4,9 +4,11 @@ from experimentation.Sets import Datasets
|
||||
from experimentation.Utils import TextColor
|
||||
from experimentation.Database import MySQL
|
||||
|
||||
report_csv = "report.csv"
|
||||
models_tree = [
|
||||
"stree",
|
||||
"wodt",
|
||||
"j48svm",
|
||||
"oc1",
|
||||
"cart",
|
||||
"baseRaF",
|
||||
@@ -15,7 +17,7 @@ models_tree = [
|
||||
]
|
||||
models_ensemble = ["odte", "adaBoost", "bagging", "TBRaF", "TBRoF", "TBRRoF"]
|
||||
title = "Best model results"
|
||||
lengths = (30, 9, 11, 11, 11, 11, 11, 11, 11)
|
||||
lengths = (30, 9, 11, 11, 11, 11, 11, 11, 11, 11)
|
||||
|
||||
|
||||
def parse_arguments() -> Tuple[str, str, str, bool, bool]:
|
||||
@@ -36,8 +38,15 @@ def parse_arguments() -> Tuple[str, str, str, bool, bool]:
|
||||
required=False,
|
||||
default="tree",
|
||||
)
|
||||
ap.add_argument(
|
||||
"-c",
|
||||
"--csv-output",
|
||||
type=bool,
|
||||
required=False,
|
||||
default=False,
|
||||
)
|
||||
args = ap.parse_args()
|
||||
return (args.experiment, args.model)
|
||||
return (args.experiment, args.model, args.csv_output)
|
||||
|
||||
|
||||
def report_header_content(title, experiment, model_type):
|
||||
@@ -103,7 +112,7 @@ def report_footer(agg):
|
||||
)
|
||||
|
||||
|
||||
(experiment, model_type) = parse_arguments()
|
||||
(experiment, model_type, csv_output) = parse_arguments()
|
||||
dbh = MySQL()
|
||||
database = dbh.get_connection()
|
||||
dt = Datasets(False, False, "tanveer")
|
||||
@@ -122,6 +131,9 @@ for item in [
|
||||
agg[item]["items"] = 0
|
||||
agg[item]["better"] = 0
|
||||
agg[item]["worse"] = 0
|
||||
if csv_output:
|
||||
f = open(report_csv, "w")
|
||||
print("dataset, classifier, accuracy", file=f)
|
||||
for dataset in dt:
|
||||
find_one = False
|
||||
# Look for max accuracy for any given dataset
|
||||
@@ -152,6 +164,8 @@ for dataset in dt:
|
||||
if accuracy == max_accuracy
|
||||
else color + item
|
||||
)
|
||||
if csv_output:
|
||||
print(f"{dataset[0]}, {model}, {accuracy}", file=f)
|
||||
if not find_one:
|
||||
print(TextColor.FAIL + f"*No results found for {dataset[0]}")
|
||||
else:
|
||||
@@ -160,4 +174,7 @@ for dataset in dt:
|
||||
)
|
||||
print(report_line(line))
|
||||
report_footer(agg)
|
||||
if csv_output:
|
||||
f.close()
|
||||
print(f"{report_csv} file generated")
|
||||
dbh.close()
|
||||
|
Reference in New Issue
Block a user