Add nodes, leaves, depth to mysql

Add nodes, leaves, depth, samples, features and classes to analysis
This commit is contained in:
2021-03-24 12:38:11 +01:00
parent ae6e2ba374
commit 66bceff179
5 changed files with 124 additions and 74 deletions

View File

@@ -2,9 +2,8 @@ import json
import os
import time
import warnings
import numpy as np
from sklearn.model_selection import GridSearchCV, cross_validate
from . import Models
from .Database import Hyperparameters, MySQL, Outcomes
from .Sets import Datasets
@@ -94,15 +93,25 @@ class Experiment:
X,
y,
return_train_score=True,
return_estimator=True,
n_jobs=self._threads,
cv=kfold,
)
for item in outcomes:
total[item].append(results[item])
print("end")
if type(model).__name__ == "Stree":
best_model = results["estimator"][np.argmax(results["test_score"])]
nodes, leaves = best_model.nodes_leaves()
depth = best_model.depth_
else:
nodes = leaves = depth = 0
complexity = dict(nodes=nodes, leaves=leaves, depth=depth)
outcomes = Outcomes(host=self._host, model=self._model_name)
parameters = json.dumps(parameters, sort_keys=True)
outcomes.store(dataset, normalize, standardize, parameters, total)
outcomes.store(
dataset, normalize, standardize, parameters, total, complexity
)
if self._num_warnings > 0:
print(f"{self._num_warnings} warnings have happend")