# Global Forecasting Using Decision Trees Contributors - ``` class GlobalForecaster:#Name to be changed def __init__(self, regressor, group_ids:List,#Ids to identify panels date_col, #Name of Date Col, target_col,#String, lags,#List of lags, differences, categorical_cols #If any, strategy,#recursive/direct ) ... def fit(X,y): X= self._transform(X) if self.strategy == "recursive": X=self._target(X) elif self.strategy == "direct": ... ... def _transform(self,data): feature_engineering = dict() for each_lag in self.lags: feature_engineering[f"lag_{each_lag}"] = \ data.groupby(self.group_ids)[self.target_col].shift(each_lag) for each_lag in self.shfts: feature_engineering[f"diff_{each_lag}"] = \ data.groupby(self.group_ids)[self.target_col].diff(each_lag) data = data.assign(**feature_engineering) def _target(self,data,shift=-1): feature_engineering[f"target"] = data.\ groupby(self.group_ids)[self.target_col].shift(shift) def _extract_seasonal_features(self): if freq=="D": features["date"] = pd.to_datetime(features["date"]) features["month"] = features["date"].dt.month.astype("category").cat.codes.values features["dayofweek"] = features["date"].dt.dayofweek.astype("category").cat.codes.values features["weekofyear"] = features["date"].dt.weekofyear.astype("category").cat.codes.values features["week_of_month"] = ... self._save_above_encoding_for_test_set def _encode_group_ids_and_categorical_cols(self: ... def predict(fh): ... ``` Points: - How to determine lags(User/Predefined) - We need to add Differences(As We can't detrend for each panel) - How to determine Differences(User/Predefined) - To capture seasonality, we need to extract calender/date features(challenge- different feature extraction for different time frequencies) - We need a Global Train Test split - Need an efficient way for recursive/direct forecast # make_panel_reduction