Skip to content

Commit

Permalink
deal with the edge case in which a QRF multistep model predicts a sin…
Browse files Browse the repository at this point in the history
…gle step
  • Loading branch information
vascomedici committed Sep 24, 2024
1 parent 4615f87 commit ae37e8b
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyforecaster/forecasting_models/randomforests.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class QRF(ScenarioGenerator):
def __init__(self, n_estimators=100, q_vect=None, val_ratio=None, nodes_at_step=None,
metadata_features=None, n_single=1, red_frac_multistep=0.5, tol_period='1h',
metadata_features=None, n_single=0, red_frac_multistep=0.5, tol_period='1h',
keep_last_n_lags=0, keep_last_seconds=0, criterion="squared_error", max_depth=None, min_samples_split=2,
min_samples_leaf=1, max_samples_leaf=1, min_weight_fraction_leaf=0.0, max_features=1.0,
max_leaf_nodes=None, min_impurity_decrease=0.0, bootstrap=True, oob_score=False, n_jobs=None,
Expand Down Expand Up @@ -159,6 +159,8 @@ def _predict(self, i, x, period, **kwargs):

def predict_multi_step(self, x, quantiles='mean'):
preds = self.multi_step_model.predict(x, quantiles)
if len(preds.shape) == 1:
preds = np.expand_dims(preds, 1)
if len(preds.shape) == 2:
preds = np.expand_dims(preds, 1)
else:
Expand Down

0 comments on commit ae37e8b

Please sign in to comment.