mirror of
https://github.com/Doctorado-ML/Stree_datasets.git
synced 2025-08-16 07:56:07 +00:00
Fix normalize error
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
||||
import os
|
||||
import time
|
||||
import warnings
|
||||
import numpy as np
|
||||
import statistics
|
||||
from sklearn.model_selection import GridSearchCV, cross_validate
|
||||
from . import Models
|
||||
from .Database import Hyperparameters, MySQL, Outcomes
|
||||
@@ -82,6 +82,9 @@ class Experiment:
|
||||
outcomes = ["fit_time", "score_time", "train_score", "test_score"]
|
||||
for item in outcomes:
|
||||
total[item] = []
|
||||
nodes_total = []
|
||||
leaves_total = []
|
||||
depths_total = []
|
||||
for random_state in [57, 31, 1714, 17, 23, 79, 83, 97, 7, 1]:
|
||||
kfold = KFold(shuffle=True, random_state=random_state, n_splits=5)
|
||||
model.set_params(**{"random_state": random_state})
|
||||
@@ -101,13 +104,19 @@ class Experiment:
|
||||
)
|
||||
for item in outcomes:
|
||||
total[item].append(results[item])
|
||||
print("end")
|
||||
if type(model).__name__ == "Stree":
|
||||
for result_item in results["estimator"]:
|
||||
nodes, leaves = result_item.nodes_leaves()
|
||||
nodes_total.append(nodes)
|
||||
leaves_total.append(leaves)
|
||||
depths_total.append(result_item.depth_)
|
||||
if type(model).__name__ == "Stree":
|
||||
best_model = results["estimator"][np.argmax(results["test_score"])]
|
||||
nodes, leaves = best_model.nodes_leaves()
|
||||
depth = best_model.depth_
|
||||
nodes = statistics.mean(nodes_total)
|
||||
leaves = statistics.mean(leaves_total)
|
||||
depth = statistics.mean(depths_total)
|
||||
else:
|
||||
nodes = leaves = depth = 0
|
||||
nodes = leaves = depth = 0.0
|
||||
print("end")
|
||||
complexity = dict(nodes=nodes, leaves=leaves, depth=depth)
|
||||
outcomes = Outcomes(host=self._host, model=self._model_name)
|
||||
parameters = json.dumps(parameters, sort_keys=True)
|
||||
|
@@ -181,7 +181,7 @@ class Datasets_Tanveer(Dataset_Base):
|
||||
)
|
||||
X = data.drop("clase", axis=1).to_numpy()
|
||||
y = data["clase"].to_numpy()
|
||||
return X, y
|
||||
return self.post_process(X, y) # type: ignore
|
||||
|
||||
|
||||
class Datasets_AAAI(Dataset_Base):
|
||||
|
Reference in New Issue
Block a user