Non stratified experiments

Remove reference column in analysis
This commit is contained in:
2021-03-22 11:02:53 +01:00
parent 6d68c81920
commit 08fb237001
6 changed files with 318 additions and 281 deletions

View File

@@ -6,8 +6,9 @@ import warnings
from sklearn.model_selection import GridSearchCV, cross_validate
from . import Models
from .Database import Hyperparameters, Outcomes, MySQL
from .Database import Hyperparameters, MySQL, Outcomes
from .Sets import Datasets
from sklearn.model_selection._split import KFold
class Experiment:
@@ -81,6 +82,7 @@ class Experiment:
for item in outcomes:
total[item] = []
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})
print(f"{random_state}, ", end="", flush=True)
with warnings.catch_warnings():
@@ -88,7 +90,12 @@ class Experiment:
# Also affect subprocesses
os.environ["PYTHONWARNINGS"] = "ignore"
results = cross_validate(
model, X, y, return_train_score=True, n_jobs=self._threads
model,
X,
y,
return_train_score=True,
n_jobs=self._threads,
cv=kfold,
)
for item in outcomes:
total[item].append(results[item])