Bug fixes
(1) creating folder for separate models in gboost_models.py & skmodels.py; (2) deepcopy in between fitting models in skmodels.py; (3) adding 'linear_model' to model_loader.py
This commit is contained in:
Родитель
88b13d8eb6
Коммит
23c9a31fe0
|
@ -115,6 +115,9 @@ class GBoostModel(BaseModel):
|
|||
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||
path_name = str(parent_dir)
|
||||
else:
|
||||
file_dir = pathlib.Path(filename)
|
||||
if not file_dir.exists():
|
||||
file_dir.mkdir(parents=True, exist_ok=True)
|
||||
path_name = filename
|
||||
pickle.dump(
|
||||
self.xscalar, open(os.path.join(path_name, "xscalar.pkl"), "wb")
|
||||
|
|
|
@ -10,6 +10,7 @@ from gboost_models import GBoostModel
|
|||
|
||||
available_models = {
|
||||
"pytorch": PyTorchModel,
|
||||
"linear_model": SKModel,
|
||||
"SVR": SKModel,
|
||||
"GradientBoostingRegressor": SKModel,
|
||||
"gboost": GBoostModel,
|
||||
|
|
|
@ -4,6 +4,7 @@ import pickle
|
|||
from typing import Dict, Tuple
|
||||
|
||||
import numpy as np
|
||||
import copy
|
||||
|
||||
from sklearn.metrics import mean_squared_error
|
||||
from sklearn.ensemble import GradientBoostingRegressor
|
||||
|
@ -70,7 +71,9 @@ class SKModel(BaseModel):
|
|||
self.models = []
|
||||
for i in range(y.shape[1]):
|
||||
logger.info(f"Fitting model {i+1} of {y.shape[1]}")
|
||||
self.models.append(self.model.fit(X, y[:, i]))
|
||||
# ensure model doesn't change in between per-output models
|
||||
aux_model = copy.deepcopy(self.model.fit(X, y[:, i]))
|
||||
self.models.append(aux_model)
|
||||
else:
|
||||
try:
|
||||
self.model.fit(X, y)
|
||||
|
@ -111,6 +114,9 @@ class SKModel(BaseModel):
|
|||
parent_dir.mkdir(parents=True, exist_ok=True)
|
||||
path_name = str(parent_dir)
|
||||
else:
|
||||
file_dir = pathlib.Path(filename)
|
||||
if not file_dir.exists():
|
||||
file_dir.mkdir(parents=True, exist_ok=True)
|
||||
path_name = filename
|
||||
pickle.dump(
|
||||
self.xscalar, open(os.path.join(path_name, "xscalar.pkl"), "wb")
|
||||
|
|
Загрузка…
Ссылка в новой задаче