Dinis Timoteo
10/04/2024, 5:10 PMJosé Morales
10/04/2024, 5:12 PMDinis Timoteo
10/04/2024, 5:13 PMJosé Morales
10/04/2024, 5:16 PMDinis Timoteo
10/04/2024, 5:19 PMDinis Timoteo
10/04/2024, 5:19 PMJosé Morales
10/04/2024, 5:23 PMmodels_
attribute for the direct approach is a dict from str to a list of models (one for each horizon), so you can override that with whatever you want as long as it matches that structure. So you could generate the targets, do hyperparameter optimization for each horizon and then set each model to its corresponding position, e.g.
X, ys = mlf.preprocess(data, max_horizon=6, return_X_y=True)
models = []
for y in ys:
mask = ~np.isnan(y)
best_model = HParamSearch.fit(X[mask], y[mask])
models.append(best_model)
mlf.models_ = {'my_model': models}
mlf.predict(...)
Dinis Timoteo
10/04/2024, 6:42 PMself.models_: Dict[str, Union[BaseEstimator, List[BaseEstimator]]] = {}
if y.ndim == 2 and y.shape[1] > 1:
############################################
for col, (name, model) in zip(range(y.shape[1]), self.models.items()):
###############################################3
self.models_[name] = []
keep = ~np.isnan(y[:, col])
if isinstance(X, np.ndarray):
Xh = X[keep]
else:
Xh = ufp.filter_with_mask(X, keep)
yh = y[keep, col]
self.models_[name].append(clone(model).fit(Xh, yh))
else:
for name, model in self.models.items():
self.models_[name] = clone(model).fit(X, y)
return self
Dinis Timoteo
10/04/2024, 6:43 PM