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

View File

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