mirror of
https://github.com/Doctorado-ML/Stree_datasets.git
synced 2025-08-16 07:56:07 +00:00
Add oc1 and cart models
Update analysis and report mysql
This commit is contained in:
@@ -44,7 +44,7 @@ class MySQL:
|
||||
self._database = mysql.connector.connect(**self._config_db)
|
||||
return self._database
|
||||
|
||||
def find_best(self, dataset, classifier="any"):
|
||||
def find_best(self, dataset, classifier="any", experiment="any"):
|
||||
cursor = self._database.cursor(buffered=True)
|
||||
if classifier == "any":
|
||||
command = (
|
||||
@@ -58,6 +58,7 @@ class MySQL:
|
||||
f"r.dataset=e.dataset where r.dataset='{dataset}' and "
|
||||
f"classifier='{classifier}' and date>='2021-01-20'"
|
||||
)
|
||||
command += "" if experiment == "any" else f" and type='{experiment}'"
|
||||
command += (
|
||||
" order by r.dataset, accuracy desc, classifier desc, "
|
||||
"type, date, time"
|
||||
@@ -163,7 +164,14 @@ class BD(ABC):
|
||||
self.execute(command)
|
||||
|
||||
def mirror(
|
||||
self, exp_type, dataset, normalize, standardize, accuracy, parameters
|
||||
self,
|
||||
exp_type,
|
||||
dataset,
|
||||
normalize,
|
||||
standardize,
|
||||
accuracy,
|
||||
time_spent,
|
||||
parameters,
|
||||
) -> None:
|
||||
"""Create a record in MySQL database
|
||||
|
||||
@@ -174,8 +182,8 @@ class BD(ABC):
|
||||
database = dbh.get_connection()
|
||||
command_insert = (
|
||||
"replace into results (date, time, type, accuracy, "
|
||||
"dataset, classifier, norm, stand, parameters) values (%s, %s, "
|
||||
"%s, %s, %s, %s, %s, %s, %s)"
|
||||
"dataset, classifier, norm, stand, parameters, accuracy_std, time_spent, time_spent_std) values (%s, %s, "
|
||||
"%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)"
|
||||
)
|
||||
now = datetime.now()
|
||||
date = now.strftime("%Y-%m-%d")
|
||||
@@ -184,12 +192,15 @@ class BD(ABC):
|
||||
date,
|
||||
time,
|
||||
exp_type,
|
||||
accuracy,
|
||||
accuracy[0],
|
||||
dataset,
|
||||
self._model,
|
||||
normalize,
|
||||
standardize,
|
||||
parameters,
|
||||
accuracy[1],
|
||||
time_spent[0],
|
||||
time_spent[1],
|
||||
)
|
||||
cursor = database.cursor()
|
||||
cursor.execute(command_insert, values)
|
||||
@@ -325,7 +336,14 @@ class Outcomes(BD):
|
||||
dataset,
|
||||
normalize,
|
||||
standardize,
|
||||
float(results["test_score"].mean()),
|
||||
[
|
||||
float(results["test_score"].mean()),
|
||||
float(results["test_score"].std()),
|
||||
],
|
||||
[
|
||||
float(results["score_time"].mean()),
|
||||
float(results["score_time"].std()),
|
||||
],
|
||||
parameters,
|
||||
)
|
||||
|
||||
@@ -414,9 +432,22 @@ class Hyperparameters(BD):
|
||||
command += ") "
|
||||
command_values += ")"
|
||||
self.execute(command + command_values)
|
||||
accuracy = float(outcomes["test_score"])
|
||||
accuracy = [
|
||||
float(outcomes["test_score"]),
|
||||
float(outcomes["test_score_std"]),
|
||||
]
|
||||
time_spent = [
|
||||
float(outcomes["score_time"]),
|
||||
float(outcomes["score_time_std"]),
|
||||
]
|
||||
self.mirror(
|
||||
grid_type, dataset, normalize, standardize, accuracy, parameters
|
||||
grid_type,
|
||||
dataset,
|
||||
normalize,
|
||||
standardize,
|
||||
accuracy,
|
||||
time_spent,
|
||||
parameters,
|
||||
)
|
||||
|
||||
def report(self, dataset, exclude_params):
|
||||
|
Reference in New Issue
Block a user