Refactor be_report and fix error in datasets

This commit is contained in:
2022-11-22 16:47:03 +01:00
parent 5d7ed6f1ed
commit f60d9365dd
2 changed files with 36 additions and 32 deletions

View File

@@ -1,4 +1,5 @@
import os import os
from types import SimpleNamespace
import pandas as pd import pandas as pd
import numpy as np import numpy as np
from scipy.io import arff from scipy.io import arff
@@ -132,11 +133,10 @@ class Datasets:
return [class_name], [dataset_name] return [class_name], [dataset_name]
def get_attributes(self, name): def get_attributes(self, name):
class Attributes: tmp = self.discretize
pass self.discretize = False
X, y = self.load(name)
X, y = self.load_continuous(name) attr = SimpleNamespace()
attr = Attributes()
values, counts = np.unique(y, return_counts=True) values, counts = np.unique(y, return_counts=True)
comp = "" comp = ""
sep = "" sep = ""
@@ -147,6 +147,7 @@ class Datasets:
attr.classes = len(np.unique(y)) attr.classes = len(np.unique(y))
attr.samples = X.shape[0] attr.samples = X.shape[0]
attr.features = X.shape[1] attr.features = X.shape[1]
self.discretize = tmp
return attr return attr
def get_features(self): def get_features(self):

View File

@@ -51,31 +51,34 @@ def main(args_test=None):
], ],
) )
args = arguments.parse(args_test) args = arguments.parse(args_test)
if args.subcommand == "best" or args.subcommand == "grid": match args.subcommand:
best = args.subcommand == "best" case "best" | "grid":
report = ReportBest(args.score, args.model, best) best = args.subcommand == "best"
report.report() report = ReportBest(args.score, args.model, best)
elif args.subcommand == "file":
try:
report = Report(args.file_name, args.compare)
report.report() report.report()
except FileNotFoundError as e: case "file":
print(e) try:
return report = Report(args.file_name, args.compare)
if args.sql: report.report()
sql = SQL(args.file_name) except FileNotFoundError as e:
sql.report() print(e)
if args.excel: return
excel = Excel( if args.sql:
file_name=args.file_name, sql = SQL(args.file_name)
compare=args.compare, sql.report()
) if args.excel:
excel.report() excel = Excel(
is_test = args_test is not None file_name=args.file_name,
Files.open(excel.get_file_name(), is_test) compare=args.compare,
else: )
report = ReportDatasets(args.excel) excel.report()
report.report() is_test = args_test is not None
if args.excel: Files.open(excel.get_file_name(), is_test)
is_test = args_test is not None case "datasets":
Files.open(report.get_file_name(), is_test) report = ReportDatasets(args.excel)
report.report()
if args.excel:
is_test = args_test is not None
Files.open(report.get_file_name(), is_test)
case _:
arguments.parse(["-h"])