All Projects β†’ Nixtla β†’ mlforecast

Nixtla / mlforecast

Licence: Apache-2.0 license
Scalable machine πŸ€– learning for time series forecasting.

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to mlforecast

magi
πŸ“ˆ high level wrapper for parallel univariate time series forecasting πŸ“‰
Stars: ✭ 17 (-82.29%)
Mutual labels:  time-series, forecast, forecasting
gpu accelerated forecasting modeltime gluonts
GPU-Accelerated Deep Learning for Time Series using Modeltime GluonTS (Learning Lab 53). Event sponsors: Saturn Cloud, NVIDIA, & Business Science.
Stars: ✭ 20 (-79.17%)
Mutual labels:  time-series, forecast, forecasting
HyperGBM
A full pipeline AutoML tool for tabular data
Stars: ✭ 172 (+79.17%)
Mutual labels:  xgboost, lightgbm, dask
modeltime.ensemble
Time Series Ensemble Forecasting
Stars: ✭ 65 (-32.29%)
Mutual labels:  time-series, forecast, forecasting
Btctrading
Time Series Forecast with Bitcoin value, to detect upward/down trends with Machine Learning Algorithms
Stars: ✭ 99 (+3.13%)
Mutual labels:  time-series, forecast, xgboost
Timetk
A toolkit for working with time series in R
Stars: ✭ 371 (+286.46%)
Mutual labels:  time-series, forecast, forecasting
Mars
Mars is a tensor-based unified framework for large-scale data computation which scales numpy, pandas, scikit-learn and Python functions.
Stars: ✭ 2,308 (+2304.17%)
Mutual labels:  xgboost, lightgbm, dask
Neural prophet
NeuralProphet - A simple forecasting model based on Neural Networks in PyTorch
Stars: ✭ 1,125 (+1071.88%)
Mutual labels:  time-series, forecast, forecasting
Forecastml
An R package with Python support for multi-step-ahead forecasting with machine learning and deep learning algorithms
Stars: ✭ 101 (+5.21%)
Mutual labels:  time-series, forecast, forecasting
Forecasting
Time Series Forecasting Best Practices & Examples
Stars: ✭ 2,123 (+2111.46%)
Mutual labels:  time-series, forecasting, lightgbm
dbnR
Gaussian dynamic Bayesian networks structure learning and inference based on the bnlearn package
Stars: ✭ 33 (-65.62%)
Mutual labels:  time-series, forecasting
ewstools
Python package for early warning signals (EWS) of bifurcations in time series data.
Stars: ✭ 29 (-69.79%)
Mutual labels:  time-series, forecasting
JLBoost.jl
A 100%-Julia implementation of Gradient-Boosting Regression Tree algorithms
Stars: ✭ 65 (-32.29%)
Mutual labels:  xgboost, lightgbm
fast retraining
Show how to perform fast retraining with LightGBM in different business cases
Stars: ✭ 56 (-41.67%)
Mutual labels:  xgboost, lightgbm
SCINet
Forecast time series and stock prices with SCINet
Stars: ✭ 28 (-70.83%)
Mutual labels:  time-series, forecasting
query-selector
LONG-TERM SERIES FORECASTING WITH QUERYSELECTOR – EFFICIENT MODEL OF SPARSEATTENTION
Stars: ✭ 63 (-34.37%)
Mutual labels:  time-series, forecasting
AutoTabular
Automatic machine learning for tabular data. ⚑πŸ”₯⚑
Stars: ✭ 51 (-46.87%)
Mutual labels:  xgboost, lightgbm
AutoTS
Automated Time Series Forecasting
Stars: ✭ 665 (+592.71%)
Mutual labels:  time-series, forecasting
CoronaDash
COVID-19 spread shiny dashboard with a forecasting model, countries' trajectories graphs, and cluster analysis tools
Stars: ✭ 20 (-79.17%)
Mutual labels:  time-series, forecasting
decision-trees-for-ml
Building Decision Trees From Scratch In Python
Stars: ✭ 61 (-36.46%)
Mutual labels:  xgboost, lightgbm

mlforecast

CI Python PyPi conda-forge License

Install

PyPI

pip install mlforecast

If you want to perform distributed training, you can instead use pip install mlforecast[distributed], which will also install dask. Note that you’ll also need to install either LightGBM or XGBoost.

conda-forge

conda install -c conda-forge mlforecast

Note that this installation comes with the required dependencies for the local interface. If you want to perform distributed training, you must install dask (conda install -c conda-forge dask) and either LightGBM or XGBoost.

How to use

The following provides a very basic overview, for a more detailed description see the documentation.

Store your time series in a pandas dataframe in long format, that is, each row represents an observation for a specific serie and timestamp.

from mlforecast.utils import generate_daily_series

series = generate_daily_series(
    n_series=20,
    max_length=100,
    n_static_features=1,
    static_as_categorical=False,
    with_trend=True
)
series.head()
ds y static_0
unique_id
id_00 2000-01-01 1.751917 72
id_00 2000-01-02 9.196715 72
id_00 2000-01-03 18.577788 72
id_00 2000-01-04 24.520646 72
id_00 2000-01-05 33.418028 72

Next define your models. If you want to use the local interface this can be any regressor that follows the scikit-learn API. For distributed training there are LGBMForecast and XGBForecast.

import lightgbm as lgb
import xgboost as xgb
from sklearn.ensemble import RandomForestRegressor

models = [
    lgb.LGBMRegressor(),
    xgb.XGBRegressor(),
    RandomForestRegressor(random_state=0),
]

Now instantiate a Forecast object with the models and the features that you want to use. The features can be lags, transformations on the lags and date features. The lag transformations are defined as numba jitted functions that transform an array, if they have additional arguments you supply a tuple (transform_func, arg1, arg2, …).

from mlforecast import Forecast
from window_ops.expanding import expanding_mean
from window_ops.rolling import rolling_mean

fcst = Forecast(
    models=models,
    freq='D',
    lags=[7, 14],
    lag_transforms={
        1: [expanding_mean],
        7: [(rolling_mean, 7)]
    },
    date_features=['dayofweek'],
    differences=[1],
)

To compute the features and train the models call fit on your Forecast object. Here you have to specify the columns that:

  • Identify each serie (id_col). If the series identifier is the index you can specify id_col='index'
  • Contain the timestamps (time_col). Can also be integers if your data doesn’t have timestamps.
  • Are the series values (target_col)
fcst.fit(series, id_col='index', time_col='ds', target_col='y', static_features=['static_0'])
Forecast(models=[LGBMRegressor, XGBRegressor, RandomForestRegressor], freq=<Day>, lag_features=['lag-7', 'lag-14', 'expanding_mean_lag-1', 'rolling_mean_lag-7_window_size-7'], date_features=['dayofweek'], num_threads=1)

To get the forecasts for the next 14 days call predict(14) on the forecast object. This will automatically handle the updates required by the features using a recursive strategy.

predictions = fcst.predict(14)
import matplotlib.pyplot as plt
import pandas as pd

fig, ax = plt.subplots(nrows=2, ncols=2, figsize=(12, 6), gridspec_kw=dict(hspace=0.3))
for i, (cat, axi) in enumerate(zip(series.index.categories, ax.flat)):
    pd.concat([series.loc[cat, ['ds', 'y']], predictions.loc[cat]]).set_index('ds').plot(ax=axi)
    axi.set(title=cat, xlabel=None)
    if i % 2 == 0:
        axi.legend().remove()
    else:
        axi.legend(bbox_to_anchor=(1.01, 1.0))
fig.savefig('figs/index.png', bbox_inches='tight')
plt.close()

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].