Skip to main content

Gradient boosted time series forecasting.

Project description

MFLES v0.2.2

alt text

A Specific implementation from ThymeBoost written with the help of Numba.

Here is a quick Introduction and demonstration of methods such as Conformal Prediction Intervals and seasonality decomposition:

https://github.com/tblume1992/MFLES/blob/main/examples/MFLES_Intro.ipynb

Here is a quick benchmark vs AutoETS from M4: alt text

Quick Start:

Install via pip

pip install MFLES

Import MFLES class

from MFLES.Forecaster import MFLES

Import data

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

df = pd.read_csv(r'https://raw.githubusercontent.com/jbrownlee/Datasets/master/airline-passengers.csv')

Fit and predict!

mfles = MFLES()
fitted = mfles.fit(df['Passengers'].values, seasonal_period=12)
predicted = mfles.predict(12)

plt.plot(np.append(fitted, predicted))
plt.plot(df['Passengers'].values)
plt.show()

alt text

Or Optimize

mfles = MFLES()
opt_params = mfles.optimize(df['Passengers'].values,
                          seasonal_period=12,
                          test_size=6,
                          n_steps=3, #number of train/test splits to make
                          step_size=6, #the number of periods to move each step
                          metric='mse' #should support smape, mse, mae, mape
                          )
fitted = mfles.fit(df['Passengers'].values, **opt_params)
predicted = mfles.predict(12)

plt.plot(np.append(fitted, predicted))
plt.plot(df['Passengers'].values)
plt.show()

Fitting from dataframe:

from MFLES.Forecaster import fit_from_df

output = fit_from_df(df,
                      forecast_horizon=24,
                      freq='M',
                      seasonal_period=12,
                      id_column='unique_id',
                      time_column='ds',
                      value_column='y',
                      floor=0)

Optimizing from dataframe

from MFLES.Forecaster import optimize_from_df

output = optimize_from_df(df,
                          forecast_horizon=4,
                          test_size=4,
                          n_steps=3,
                          step_size=1,
                          metric='mse',
                          seasonal_period=12,
                          freq='M')

Gradient Boosted Time Series Decomposition Theory

The idea is pretty simple, take a process like decomposition and view it as a type of 'psuedo' gradient boosting since we are passing residuals around simlar to standard gradient boosting. Then apply gradient boosting approaches such as iterating with a global mechanism to control the process and introduce learning rates for each of the components in the process such as trend or seasonality or exogenous. By doing this we graduate from this 'psuedo' approach to full blown gradient boosting.

This process allows us to fit pretty exotic models and optimize for each learning rate to make them jive. Also enables online learning since the framework is made for residuals. Also opens up changepoint detection using segmentation schemes although that is out-of-scope of this library.

Citing

@software{
author = {Blume Tyler},
license = {MIT License},
title = {{MFLES}},
url = {https://github.com/tblume1992/MFLES},
version = {0.2.2},
year = {2024}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

MFLES-0.2.4-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file MFLES-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: MFLES-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.15

File hashes

Hashes for MFLES-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 202dda077398a281c24130c9ff2a599b1dfebe4a90cb0d59f073a4e22a62adf1
MD5 64c2efceb5a14ef6790b4ab59152bc69
BLAKE2b-256 5cc23457053a4379968579e4fb89255d4e3079e2b784e712fcdf8c2e6373b3f5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page