from lightgbm import LGBMRegressor
from fastcore.test import test_fail

from mlforecast import MLForecast
from mlforecast.utils import generate_daily_series
series = generate_daily_series(5)
fcst = MLForecast({'lgb': LGBMRegressor(verbosity=-1)}, freq='D', date_features=['dayofweek'])
fcst.fit(series)
all_preds = fcst.predict(1)
all_preds
unique_iddslgb
0id_02000-08-103.728396
1id_12000-04-074.749133
2id_22000-06-164.749133
3id_32000-08-302.758949
4id_42001-01-083.331394

By default all series seen during training will be forecasted with the predict method. If you’re only interested in predicting a couple of them you can use the ids argument.

fcst.predict(1, ids=['id_0', 'id_4'])
unique_iddslgb
0id_02000-08-103.728396
1id_42001-01-083.331394

Note that the ids must’ve been seen during training, if you try to predict an id that wasn’t there you’ll get an error.

test_fail(lambda: fcst.predict(1, ids=['fake_id']), contains='fake_id')