Data setup
fit and cross_validation methods
MLForecast
all you have to do to train with numpy arrays is provide the as_numpy
argument, which will cast the features to an array before passing them
to the models.
unique_id | ds | lr | lgbm | |
---|---|---|---|---|
0 | id_0 | 2000-08-10 | 5.268787 | 6.322262 |
1 | id_1 | 2000-04-07 | 4.437316 | 5.213255 |
2 | id_2 | 2000-06-16 | 3.246518 | 4.373904 |
3 | id_3 | 2000-08-30 | 0.144860 | 1.285219 |
4 | id_4 | 2001-01-08 | 2.211318 | 3.236700 |
as_numpy=True
.
preprocess method
Having the features as a numpy array can also be helpful in cases where you have categorical columns and the library doesn’t support them, for example LightGBM with polars. In order to use categorical features with LightGBM and polars we have to convert them to their integer representation and tell LightGBM to treat those features as categorical, which we can achieve in the following way:unique_id | ds | y | static_0 |
---|---|---|---|
cat | datetime[ns] | f64 | cat |
”id_0” | 2000-01-01 00:00:00 | 36.462689 | ”84" |
"id_0” | 2000-01-02 00:00:00 | 121.008199 | ”84” |
fcst.ts.features_order_
unique_id | ds | lgbm |
---|---|---|
cat | datetime[ns] | f64 |
”id_0” | 2000-08-10 00:00:00 | 448.796188 |
”id_1” | 2000-04-07 00:00:00 | 81.058211 |
”id_2” | 2000-06-16 00:00:00 | 4.450549 |
”id_3” | 2000-08-30 00:00:00 | 14.219603 |
”id_4” | 2001-01-08 00:00:00 | 87.361881 |