pip install mlforecast
conda install -c conda-forge mlforecast
For more detailed instructions you can refer to the installation
page.
MLForecast
includes efficient feature engineering to train any machine learning
model (with fit
and predict
methods such as
sklearn
) to fit millions of time
series.
sklearn
syntax: .fit
and .predict
.unique_id | ds | y | static_0 | |
---|---|---|---|---|
0 | id_00 | 2000-01-01 | 17.519167 | 72 |
1 | id_00 | 2000-01-02 | 87.799695 | 72 |
2 | id_00 | 2000-01-03 | 177.442975 | 72 |
3 | id_00 | 2000-01-04 | 232.704110 | 72 |
4 | id_00 | 2000-01-05 | 317.510474 | 72 |
Note: The unique_id serves as an identifier for each distinct time series in your dataset. If you are using only single time series from your dataset, set this column to a constant value.
MLForecast
object with the models and the features that you want to use. The
features can be lags, transformations on the lags and date features. You
can also define transformations to apply to the target before fitting,
which will be restored when predicting.
fit
on your
Forecast
object.
n
days call predict(n)
on the
forecast object. This will automatically handle the updates required by
the features using a recursive strategy.
unique_id | ds | LGBMRegressor | LinearRegression | |
---|---|---|---|---|
0 | id_00 | 2000-04-04 | 299.923771 | 311.432371 |
1 | id_00 | 2000-04-05 | 365.424147 | 379.466214 |
2 | id_00 | 2000-04-06 | 432.562441 | 460.234028 |
3 | id_00 | 2000-04-07 | 495.628000 | 524.278924 |
4 | id_00 | 2000-04-08 | 60.786223 | 79.828767 |
… | … | … | … | … |
275 | id_19 | 2000-03-23 | 36.266780 | 28.333215 |
276 | id_19 | 2000-03-24 | 44.370984 | 33.368228 |
277 | id_19 | 2000-03-25 | 50.746222 | 38.613001 |
278 | id_19 | 2000-03-26 | 58.906524 | 43.447398 |
279 | id_19 | 2000-03-27 | 63.073949 | 48.666783 |