Gradient boosted time series forecasting.
Project description
MFLES v0.2.2
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:
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()
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file MFLES-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: MFLES-0.2.2-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.7.15
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b3c70e24abe400b39b7977a3fa7cb55d461b045085654ba1413387a59e16128 |
|
MD5 | 1ae26c9cff3f5c3591b098eca963af53 |
|
BLAKE2b-256 | e16c5f3ff75f8ce57303304f04d3161b1da19405ed6d22363e7b1708a6382b8a |