Skip to content

Commit

Permalink
automatically encode categorical features in QRF
Browse files Browse the repository at this point in the history
  • Loading branch information
vascomedici committed Sep 5, 2024
1 parent 08f6312 commit e1dfe95
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 @@ -2,7 +2,7 @@
import pandas as pd
from pyforecaster.utilities import get_logger
from tqdm import tqdm
from pyforecaster.forecaster import ScenarioGenerator
from pyforecaster.forecaster import ScenarioGenerator, encode_categorical
import numpy as np
import concurrent.futures
from time import time
Expand Down Expand Up @@ -94,6 +94,7 @@ def _fit(self, i, x, y):
model = RandomForestQuantileRegressor(**self.qrf_pars).fit(x_i, y.iloc[:, i], sparse_pickle=True)
return model

@encode_categorical
def fit(self, x, y):
x, y, x_val, y_val = self.train_val_split(x, y)
if self.parallel:
Expand Down Expand Up @@ -135,6 +136,7 @@ def fit(self, x, y):
super().fit(x_val, y_val)
return self

@encode_categorical
def predict(self, x, **kwargs):
preds = []
period = kwargs['period'] if 'period' in kwargs else '24h'
Expand Down

0 comments on commit e1dfe95

Please sign in to comment.