Skip to main content

Lightweight univariate time-series forecasting with auto-tuned models — NumPy only.

Project description

randomstatsmodels

Check out medium story here: Medium Story

Lightweight univariate time-series forecasting with auto-tuned models — NumPy only, no heavy dependencies.

19 forecasting models with a unified .fit(y) / .predict(h) API. Each Auto* wrapper grid-searches hyperparameters on a validation split and refits the best configuration on the full series.

Installation

pip install randomstatsmodels

Requires: Python 3.9+ and NumPy.


Quick Start

from randomstatsmodels import AutoKoopman, AutoPolymath, AutoSSA
import numpy as np

rng = np.random.default_rng(42)
t = np.arange(200)
y = 10 + 0.05 * t + np.sin(2 * np.pi * t / 24) + 0.1 * rng.normal(size=t.size)

h = 12  # forecast horizon

model = AutoKoopman().fit(y)
yhat = model.predict(h)
print("Forecast:", yhat[:5])
print("Best config:", model.best_)

Models

19 models organised by approach. Every Auto* class accepts a parameter grid, fits/evaluates candidates, and exposes .fit(y) and .predict(h).

Classical

Model Description
AutoNaive Baselines: last value, seasonal, drift, mean
AutoHoltWinters Triple exponential smoothing (level + trend + seasonal)
AutoThetaAR Theta method with AR(1) residual correction
AutoFourier Harmonic regression with optional linear trend

Regression-Based

Model Description
AutoNEO Nonlinear Evolution Operator — polynomial AR features
AutoPolymath Polynomial + Fourier basis + ridge regression
AutoLocalLinear Weighted local regression with exponential decay
AutoPALF Proximal Aggregation Lag Forecaster — penalised lag weighting

Decomposition / Spectral

Model Description
AutoSSA Singular Spectrum Analysis — SVD on trajectory matrix
AutoKoopman Dynamic Mode Decomposition / Koopman operator via delay embedding
AutoSpectralGradient Spectral derivative flow — extrapolates Fourier mode dynamics

Advanced / Calculus-Based

Model Description
AutoFracDiff Fractional calculus — Grunwald-Letnikov fractional differencing + AR
AutoGreensKernel Integral equation — Green's function convolution kernel
AutoPDEField Partial differential equations — advection-diffusion on time-scale field
AutoVariationalPath Calculus of variations — Euler-Lagrange optimal path

Hybrid / Meta

Model Description
AutoHybridForecaster Linear (Fourier + trend + AR) + GRU residual network
AutoMELD Multiscale embedding with Random Fourier Features + kNN
AutoRIFT Recursive Information Flow Tensor — information-channel dynamics
AutoEnsemble Combines multiple base forecasters with learned weights

Advanced Ensembles

Model Description
AutoStacked Meta-learner stacking — ridge regression on base model predictions
AutoBagged Block-bootstrap bagging — median of models trained on resampled series
AutoDynamic Horizon-adaptive weighting — model weights change per forecast step

Benchmarks

All 27 models evaluated on 36 real-world time series (20% holdout), ranked by MAE. Includes 5 industry-standard statsforecast baselines for comparison.

Overall Rankings

Rank Model Type Avg Rank #1st #Top3 Mdn sMAPE
1 SF_AutoARIMA statsforecast 8.36 4 9 6.43%
2 AutoHybridForecaster randomstatsmodels 8.44 0 9 8.92%
3 AutoPolymath randomstatsmodels 9.28 2 8 9.54%
4 SF_AutoTBATS statsforecast 9.56 1 7 10.71%
5 AutoNEO randomstatsmodels 9.85 1 8 13.57%
6 AutoKoopman randomstatsmodels 10.31 3 5 13.00%
7 AutoDynamic ensemble 10.50 2 4 12.01%
8 SF_AutoCES statsforecast 10.56 4 9 10.27%
9 SF_AutoETS statsforecast 11.67 1 2 11.46%
10 AutoSSA randomstatsmodels 11.97 2 4 10.80%
11 AutoKNN randomstatsmodels 12.82 2 9 11.74%
12 AutoNaive randomstatsmodels 12.83 2 3 12.56%
13 SF_AutoTheta statsforecast 12.86 1 4 12.23%
14 AutoLocalLinear randomstatsmodels 13.58 2 3 13.30%
15 AutoFourier randomstatsmodels 14.19 2 4 18.93%
16 AutoMELD randomstatsmodels 14.32 1 3 13.88%
17 AutoGreensKernel randomstatsmodels 14.33 2 4 17.46%
18 AutoPALF randomstatsmodels 15.14 2 2 13.89%
19 AutoThetaAR randomstatsmodels 15.47 0 1 24.03%
20 AutoBagged ensemble 16.31 1 4 24.07%
21 AutoPDEField randomstatsmodels 16.89 0 2 23.29%
22 AutoSpectralGradient randomstatsmodels 17.19 0 1 16.28%
23 AutoHoltWinters randomstatsmodels 17.86 1 2 23.47%
24 AutoVariationalPath randomstatsmodels 18.28 0 1 18.16%
25 AutoRIFT randomstatsmodels 19.06 0 0 29.67%
26 AutoStacked ensemble 20.06 0 0 46.70%
27 AutoFracDiff randomstatsmodels 23.58 0 0 88.03%

Dataset Coverage

36 real-world datasets across 11 challenge categories:

Category Datasets
Trend + Seasonality AirPassengers, MilkProduction, JohnsonJohnson, AusBeer, CO2, WineSales
Pure Seasonality Nottem, USAccDeaths, UKGas, MelbourneTemp
Trend-Dominant Shampoo, USGDPGrowth, WorldPopulation
Cyclical Sunspots, Lynx, SOI
Level Shift Nile, UKDriverDeaths, LakeHuron
Volatile / Financial GoldPrice, USIndProduction
Short Series TornadoDeaths, WheatYield, Discoveries, USStrikes
Long Memory NileMinLevel, GlobalTemp
Count / Intermittent VolcanicEruptions, IntlAirline, LondonRain
Nonlinear SingaporeHumidity, FedFundsRate, ChampagneSales
Additional PigSlaughter, HousingStarts, WikiPageviews

Key Findings

  • SF_AutoARIMA (statsforecast) edges out as #1 overall — the industry gold standard
  • AutoHybridForecaster is the best randomstatsmodels model (#2) — linear + GRU residuals
  • AutoPolymath is the best fast single model (#3) — polynomial + Fourier + ridge
  • AutoKoopman (#6) — Koopman/DMD eigenvalue propagation, extremely fast, best on CO2 and FedFunds
  • AutoDynamic (#7) — horizon-adaptive ensemble, best median sMAPE among our ensembles
  • No single model dominates — model selection matters for your data type

Benchmarking Your Own Data

from randomstatsmodels.benchmarking.datasets import load_datasets
from randomstatsmodels.benchmarking.evaluation import evaluate_all, print_summary
from randomstatsmodels import AutoKoopman, AutoPolymath, AutoSSA

datasets = load_datasets()
results = evaluate_all([AutoKoopman, AutoPolymath, AutoSSA], datasets)
print_summary(results["summary"])

Metrics

from randomstatsmodels.metrics import mae, mse, rmse, mape, smape

The evaluation framework also provides MASE, MSSE, and Median Absolute Error.


License

MIT

Project details


Download files

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

Source Distribution

randomstatsmodels-3.1.1.tar.gz (101.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

randomstatsmodels-3.1.1-py3-none-any.whl (115.0 kB view details)

Uploaded Python 3

File details

Details for the file randomstatsmodels-3.1.1.tar.gz.

File metadata

  • Download URL: randomstatsmodels-3.1.1.tar.gz
  • Upload date:
  • Size: 101.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.1

File hashes

Hashes for randomstatsmodels-3.1.1.tar.gz
Algorithm Hash digest
SHA256 0a38ab53a11e8f8746a934b00917edaef3a9b01d3d95b0d40b03ffdf01fd4de7
MD5 65ab26129cbdac82ed1e586ee3473517
BLAKE2b-256 9b1b60ebaeb3c6bee813c665526255642e2119ef2c34d632a6a5ab3749320ddd

See more details on using hashes here.

File details

Details for the file randomstatsmodels-3.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for randomstatsmodels-3.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 955e88ddb3595e414ce5f81e2eab7eb3fda0e11ee614b2f3fd377d674de66aa6
MD5 124d581ceccb22c100b1ecba96ea2530
BLAKE2b-256 d1703d2613380b320cb82038b94b93c1ace959ae8c51cf56296ee9f70fca3e46

See more details on using hashes here.

Supported by

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