Repository navigation
[ENH] Add FourTheta forecaster - #3983
TonyBagnall wants to merge 3 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Thank you for contributing to
|
resolves #3982
Adds
aeon.forecasting.stats.FourTheta, the generalised Theta method of Spiliotis, Assimakopoulos & Makridakis (2020). aeon has classicThetaandDOTM, but nothing with exponential trends, multiplicative expressions or per-series model selection. The method beats classic Theta at every frequency in the paper.The class follows the authors'
AutoThetaR code: 3 candidates per series, or 5 if it tests as seasonal, from a pool of 8, with θ in [1, 3] chosen by in-sample MAE. It is named after the authors'FourThetafunction, because statsforecast'sAutoThetais a different algorithm.Changes
aeon/forecasting/stats/_four_theta.py: the forecaster.aeon/forecasting/utils/_brent.py: Brent's method, matching R'soptimizeevaluation by evaluation. It uses reverse communication because numba cannot cache a function that takes a function argumentaeon/forecasting/utils/_seasonality.py:_seasonal_decompose_numbaand_seasonal_forecastmoved from_dotm.py, plus a newacf_seasonal_test. DOTM calls the test on the differenced series, FourTheta on the raw series. DOTM's test gave identical results to the old version on 5,000 random series.Why it is fast
R reruns
decompose,lmand a Nelder-Meadetsat every θ evaluation. Here each is computed once per candidate. With α fixed the SES errors are linear in the initial level, sol0is solved in closed form and SES reduces to a 1D search.Benchmark
Full M4 against the authors' actual submission (
submission-005, which used their 12-model M4 code):Timings in this table were taken with 16 processes. Equivalence holds at every frequency on both metrics (TOST on per-series log ratios, ±5% margin): overall ratios to 005 are 0.9996 for sMAPE and 1.0006 for MASE. All forecasts are finite.
The authors'
AutoThetaR code (R 4.5.3, forecast 9.0.2) on 600 yearly, quarterly and monthly series:Single-threaded:
ThetaFourThetaAutoThetaAutoETSOn a shared 60-series subset,
FourThetatook 1.1 ms and RAutoTheta465 ms, a ratio of about 440.Deliberate differences from the R code
A A Expwith non-positive adjusted data takes the log of a negative in R, which recycles a shorter vector with only a warning. This occurred in the benchmark sample.acfsilently returns NA, meaning not seasonal, whenm > 10 log10(n).Review carefully
_brent.pyreverse communication, and whether it should be a public utility.predict(y)returns the stored forecast, asETSdoes, and ignoresy.residuals_is stored so they can be added.l0differ slightly.🤖 Generated with Claude Code