Fix some mistakes

Add complexity to crossval
Change header of tex file
Add complexity fields to report_score
Add commented final date in database
This commit is contained in:
2021-04-08 08:32:22 +02:00
parent a23bae6b52
commit e592a33962
5 changed files with 43 additions and 70 deletions

View File

@@ -119,7 +119,9 @@ def process_dataset(dataset, verbose, model, auto_params):
return scores, times, json.dumps(hyperparameters), nodes, leaves, depth
def store_string(dataset, model, accuracy, time_spent, hyperparameters):
def store_string(
dataset, model, accuracy, time_spent, hyperparameters, complexity
):
attributes = [
"date",
"time",
@@ -133,6 +135,9 @@ def store_string(dataset, model, accuracy, time_spent, hyperparameters):
"time_spent",
"time_spent_std",
"parameters",
"nodes",
"leaves",
"depth",
]
command_insert = (
"replace into results ("
@@ -144,6 +149,7 @@ def store_string(dataset, model, accuracy, time_spent, hyperparameters):
now = datetime.now()
date = now.strftime("%Y-%m-%d")
time = now.strftime("%H:%M:%S")
nodes, leaves, depth = complexity.values()
values = (
date,
time,
@@ -152,11 +158,14 @@ def store_string(dataset, model, accuracy, time_spent, hyperparameters):
np.std(accuracy),
dataset,
model,
True,
False,
1,
0,
np.mean(time_spent),
np.std(time_spent),
hyperparameters,
nodes,
leaves,
depth,
)
result = command_insert % values
return result
@@ -210,14 +219,15 @@ if dataset == "all":
samples, features = X.shape
classes = len(np.unique(y))
print(
f"{dataset[0]:30s} {samples:4d} {features:3d} " f"{classes:3d} ",
f"{dataset[0]:30s} {samples:4d} {features:3d} {classes:3d} ",
end="",
)
scores, times, hyperparameters, nodes, leaves, depth = process_dataset(
dataset[0], verbose=False, model=model, auto_params=auto_params
)
complexity = dict(nodes=nodes, leaves=leaves, depth=depth)
print(
f"{nodes:2d} {leaves:2d} " f"{depth:2d} ",
f"{nodes:2d} {leaves:2d} {depth:2d} ",
end="",
)
record = dbh.find_best(dataset[0], model, "crossval")
@@ -242,7 +252,7 @@ if dataset == "all":
)
if sql:
command = store_string(
dataset[0], model, scores, times, hyperparameters
dataset[0], model, scores, times, hyperparameters, complexity
)
print(command, file=sql_output)
else:
@@ -259,7 +269,7 @@ else:
)
print(f"* Accuracy Best .....: {accuracy_best:6.4f}±{acc_best_std:6.4f}")
print(f"* Difference ........: {accuracy_best - accuracy:6.4f}")
print(f"* Nodes/Leaves/Depth : {nodes:2d} {leaves:2d} " f"{depth:2d} ")
print(f"* Nodes/Leaves/Depth : {nodes:2d} {leaves:2d} {depth:2d} ")
stop = time.time()
print(f"- Auto Hyperparams ..: {hyperparameters}")
hours, rem = divmod(stop - start, 3600)