Tyler Blume
05/04/2023, 8:15 PMfede (nixtla) (they/them)
05/04/2023, 9:04 PMcategory
type and the sklearn API of lightgbm (LGMBRegressor
) will handle them by default. Also if you want to use the unique_id
as a static variable, you need to create a separate column. And to use it as a categorical feature you need to convert it to category.
Here’s an example (unique_id
already is of type category
):
import lightgbm as lgb
from mlforecast import MLForecast
from mlforecast.utils import generate_daily_series
series = generate_daily_series(100, equal_ends=True, n_static_features=2, static_as_categorical=True)
series['my_id_col'] = series['unique_id'].copy()
mlf = MLForecast(
models=lgb.LGBMRegressor(),
freq='D',
lags=[7],
)
mlf.fit(series, static_features=['my_id_col', 'static_0', 'static_1'])
preds = mlf.predict(12)
Tyler Blume
05/04/2023, 10:56 PMfede (nixtla) (they/them)
05/17/2023, 8:44 PMTyler Blume
06/22/2023, 7:40 PMfede (nixtla) (they/them)
07/04/2023, 9:16 PMTyler Blume
07/04/2023, 10:56 PMJosé Morales
07/15/2023, 6:07 PM