Skip to content

Commit

Permalink
fixed bug in QRF predict_quantiles
Browse files Browse the repository at this point in the history
  • Loading branch information
vascomedici committed Sep 9, 2024
1 parent d7a20c4 commit d522cab
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 12 deletions.
1 change: 0 additions & 1 deletion pyforecaster/forecasting_models/randomforests.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ def predict(self, x, **kwargs):
else:
if len(preds.shape) == 2:
preds = np.expand_dims(preds, 0)
preds = np.swapaxes(preds, 1, 2)
preds = self.quantiles_to_df(preds, index=x.index, q_vect=kwargs['quantiles'])
else:
preds = pd.DataFrame(np.atleast_2d(np.squeeze(preds)), index=x.index, columns=self.target_cols)
Expand Down
11 changes: 0 additions & 11 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,17 +188,6 @@ def test_qrf(self):
formatter.add_target_transform(['all'], lags=-np.arange(6))
formatter.add_target_normalizer(['all'], 'mean', agg_freq='3d', name='a_movingavg')
formatter.add_target_normalizer(['all'], 'std', agg_freq='3d', name='a_movingstd')

#m_lin = LinearForecaster(val_ratio=0.2, formatter=formatter).fit(x_tr, y_tr)
#y_hat_nonorm = m_lin.predict(x_te)
#q_nonorm = m_lin.predict_quantiles(x_te)

#m_lgb = LGBForecaster(val_ratio=0.5, lgb_pars={'num_leaves':20}, formatter=formatter).fit(x_tr, y_tr)
#y_hat_lgb = m_lgb.predict(x_te)
#mae = lambda x, y: np.abs(x-y).mean().mean()
#print('MAE lin:', mae(y_te, y_hat_nonorm))


formatter.add_normalizing_fun(expr="(df[t] - df['a_movingavg']) / (df['a_movingstd'] + 1)",
inv_expr="df[t]*(df['a_movingstd']+1) + df['a_movingavg']")
x, y_norm = formatter.transform(self.data.iloc[:1000])
Expand Down

0 comments on commit d522cab

Please sign in to comment.