Skip to main content

Forecasting and time series analysis with single-source-of-error state-space models (ADAM, ETS, ARIMA, occurrence, SMA)

Project description

smooth

PyPI version PyPI - Downloads Python versions Python CI License: LGPL-2.1

hex-sticker of the smooth package for Python

Python implementation of the smooth package for forecasting and time series analysis using Single Source of Error (SSOE) state-space models.

The package includes the following models:

  • ADAM - Augmented Dynamic Adaptive Model, uniting exponential smoothing, ARIMA and regression, implemented in the ADAM class.
  • ETS - Exponential Smoothing in the SSOE state space form, implemented in the ES class.
  • MSARIMA - Multiple seasonal ARIMA in state space form, implemented in the MSARIMA class (fixed orders) and AutoMSARIMA class (automatic order selection).
  • OM - Occurrence Model for intermittent demand, implemented in the OM class (plus OMG for the general two-component model and AutoOM for automatic type selection).
  • SMA - Simple Moving Average in state-space form (an AR(m) model with fixed coefficients), implemented in the SMA class with automatic order selection.

All of these are implemented with the support of the following features:

  • Automatic components selection in ETS and forecasts combination
  • Explanatory variables
  • Multiple seasonal models (e.g. for high frequency data)
  • Advanced loss functions
  • Fine tuning of any elements of ADAM/ETS/ARIMA/Regression
  • A variety of prediction interval construction methods

Like the R version, the Python smooth depends on the greybox package for distributions, information criteria, regressor selection, and the LOWESS smoother. It is installed automatically as a dependency.

Installation

From PyPI (recommended):

pip install smooth

From source (development):

pip install "git+https://github.com/config-i1/smooth.git@master#subdirectory=python"

See the Installation Guide for platform-specific instructions.

System Requirements

If installing from source, this package requires compilation of C++ extensions. Before installing, ensure you have:

  • C++ compiler (g++, clang++, or MSVC)
  • CMake >= 3.25
  • Armadillo linear algebra library

Quick Example

import numpy as np
from smooth import ADAM

# Sample data
y = np.array([10, 12, 15, 13, 16, 18, 20, 19, 22, 25, 28, 30,
              11, 13, 16, 14, 17, 19, 21, 20, 23, 26, 29, 31])

# Fit ADAM model with additive error, no trend, no seasonality
model = ADAM(model="ANN")
model.fit(y)

# Generate forecasts
forecasts = model.predict(h=12)

# With seasonal component (monthly data, annual seasonality)
model = ADAM(model="ANA", lags=[1, 12])
model.fit(y)
forecasts = model.predict(h=12)

ADAMX — ADAM with Explanatory Variables

This also works with the exponential smoothing (ETSX) via the ES() class.

import numpy as np
from smooth import ADAM

# Simulate data where y depends on two external regressors
rng = np.random.default_rng(42)
n = 120
X = rng.standard_normal((n, 2))
y = 10 + 2 * X[:, 0] - 1.5 * X[:, 1] + rng.standard_normal(n)

# Fit ETSX(AAN) — use all regressors with fixed coefficients
model = ADAM(model="AAN", regressors="use")
model.fit(y, X)
print(model)           # shows fitted coefficients including xreg

# Forecast 12 steps ahead with future regressor values
X_future = rng.standard_normal((12, 2))
fc = model.predict(h=12, X=X_future)
print(fc.mean)

# Automatic variable selection (drops insignificant regressors)
model_sel = ADAM(model="AAN", regressors="select")
model_sel.fit(y, X)

# Adaptive (time-varying) regressor coefficients
model_adp = ADAM(model="AAN", regressors="adapt")
model_adp.fit(y, X)

X accepts a NumPy array or a pandas DataFrame (column names are preserved as regressor names). regressors controls treatment: "use" (fixed coefficients), "select" (stepwise selection via greybox), or "adapt" (ETS-style time-varying coefficients).

AutoMSARIMA — Automatic ARIMA Order Selection

AutoMSARIMA selects the best ARIMA orders automatically using information criteria, mirroring R's auto.msarima(). It fixes distribution="dnorm" and uses pure ARIMA (no ETS components).

import numpy as np
from smooth import AutoMSARIMA

# Monthly time series (e.g. AirPassengers, 144 observations)
y = np.array([
    112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118,
    # ... remaining observations
], dtype=float)

# Automatic seasonal ARIMA — searches up to ARIMA(3,2,3)(3,1,3)[12]
model = AutoMSARIMA(lags=[1, 12])
model.fit(y)
print(model)   # AutoMSARIMA: ARIMA([p,P],[d,D],[q,Q])

# Reduce search space for speed
model = AutoMSARIMA(
    lags=[1, 12],
    ar_order=[2, 1],   # max AR: p≤2 at lag 1, P≤1 at lag 12
    i_order=[2, 1],    # max I:  d≤2 at lag 1, D≤1 at lag 12
    ma_order=[2, 1],   # max MA: q≤2 at lag 1, Q≤1 at lag 12
)
model.fit(y)
fc = model.predict(h=24)

Documentation

The pages below document the models and their Python classes:

  • ADAM — Augmented Dynamic Adaptive Model — unified ETS/ARIMA/regression framework
  • AutoADAM — Automatic ADAM with distribution and ARIMA order selection
  • ES — Exponential Smoothing (ETS) wrapper for ADAM
  • MSARIMA — Multiple Seasonal ARIMA (fixed orders) and automatic selection (AutoMSARIMA)
  • OM — Occurrence Model for intermittent demand (OM, OMG, AutoOM)
  • SMA — Simple Moving Average in state-space form with automatic order selection

Book: Svetunkov, I. (2023). Forecasting and Analytics with the Augmented Dynamic Adaptive Model (ADAM). Chapman and Hall/CRC. Online: https://openforecast.org/adam/

See Also

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

smooth-1.0.4.tar.gz (12.0 MB view details)

Uploaded Source

Built Distributions

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

smooth-1.0.4-cp314-cp314-win_amd64.whl (639.2 kB view details)

Uploaded CPython 3.14Windows x86-64

smooth-1.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.6 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

smooth-1.0.4-cp314-cp314-macosx_11_0_arm64.whl (604.9 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

smooth-1.0.4-cp313-cp313-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.13Windows x86-64

smooth-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.6 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

smooth-1.0.4-cp313-cp313-macosx_11_0_arm64.whl (604.7 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

smooth-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl (636.8 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

smooth-1.0.4-cp312-cp312-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.12Windows x86-64

smooth-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.6 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

smooth-1.0.4-cp312-cp312-macosx_11_0_arm64.whl (604.6 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

smooth-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl (636.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

smooth-1.0.4-cp311-cp311-win_amd64.whl (629.2 kB view details)

Uploaded CPython 3.11Windows x86-64

smooth-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.6 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

smooth-1.0.4-cp311-cp311-macosx_11_0_arm64.whl (606.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

smooth-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl (635.2 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

Details for the file smooth-1.0.4.tar.gz.

File metadata

  • Download URL: smooth-1.0.4.tar.gz
  • Upload date:
  • Size: 12.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smooth-1.0.4.tar.gz
Algorithm Hash digest
SHA256 18eafa1b79a6977d797ab56316dd97802e3a2710de547199cf6bbb249e6506fb
MD5 c45b51826b626ebb133f600e6e3c5853
BLAKE2b-256 c8f3b18bbae486d66d4e7057697292c766fa769eee5ba6c5c82016141a4c2f54

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4.tar.gz:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp314-cp314-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.4-cp314-cp314-win_amd64.whl
  • Upload date:
  • Size: 639.2 kB
  • Tags: CPython 3.14, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smooth-1.0.4-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 d090112f514f9a4e37fdee3cdc5a3c2c187418ec6feadae01e0549eb0be0d3bb
MD5 6325f5ff35477cd3bb07b01eae41f8c8
BLAKE2b-256 f625399512500f0afe59f94d1c83dc2083c525f0ef88e3e73ba63693f802cc40

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp314-cp314-win_amd64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fa9d06e88e32c17ff77d9d0943307ae07917975d4ee942555e645ff0892c94a7
MD5 0cd4bb97823e18317a8a33c2f7e71937
BLAKE2b-256 baaa3724c4e31cbe58cf7e2acb2fafaf2747ddb7c0ae55d3cb83aef0384ca1ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d76b302d8a455f5505d9e9338a2d0fdc3a7dd8063290ee8494cb35561667b547
MD5 936b93f4a8f42867d1b17a59774d9993
BLAKE2b-256 6c71d546c41d84be5176b9dcfa48492f72f41ced7e044f4f276ef1682a0bc66d

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp314-cp314-macosx_11_0_arm64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.4-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 630.7 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smooth-1.0.4-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 481c9a8a6ee52ac08fb6de85be331ac246586c13846f9b77cfed68821bad7fde
MD5 4bae755e7bd4c62842d50563fa92c5c0
BLAKE2b-256 9df574dd5c2fc35f6eb354a13a2e937a7952f8d77fff44c08ea69b294b9beb54

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp313-cp313-win_amd64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d1d7e21a93644ab1c186bfa91a17060cbd03db64bad677dd64ab9ecc07662dfe
MD5 7373e31f799dd57887cf3dace785bee3
BLAKE2b-256 c841cfa49c7290cd07fe746af11a735fd629ae795cdc1d6ff753e802dbcb9330

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 386923bac6071fcf7877c26a825622f288f99f8a2e4c8abbb32b628b06a078b4
MD5 9e321acc85462b551d26b950dcfe1e00
BLAKE2b-256 99f29b31a826acc4434ba93a65d9bd98cfe43b0b0deaa7a44c4b21ba12e3fa12

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ca8e1f37d407875969f98c604e17cd2830cbcfeab1d945dcc88d11dac767112e
MD5 fdf645387c56514d41928b3ced7241f0
BLAKE2b-256 9afbfce175d7da1a29b808f2aaa8a7ec8777c5866ebcd6f9c11ca144e198056b

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp313-cp313-macosx_10_13_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.4-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 630.7 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smooth-1.0.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 53f146ace2036bdc3c056604dfb6659d46df8def2009152779bac2e5cca272ba
MD5 6486610e10a46f96bd6f115228656a5b
BLAKE2b-256 cf4658bfbd67b1b46e91b47c8f418f389f951b214940b599fa70827ab4a8b0a9

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp312-cp312-win_amd64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d9dbe54b4663a4ce24f8484cb7c1189869b04d6637b16fb06f9df388d0be47e
MD5 8495395c42509e263c9a3cc35c43ff29
BLAKE2b-256 0a4c9cd6ea5b15793508fbf00c19240c2033c24f8adb60b21e10be528558ebb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26ea394021502e46b1a359eeb205bd60d12d761ab85158464ef97c3382bb57ba
MD5 c5bad548243431def72e970e2b32a3fe
BLAKE2b-256 8257cb0d761e5a1dcae8fac9c535bec22d43020e66e6da83e2b92388d2fbf40f

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 062d2c7de5ad1138efb11e26beb5c214e32273875cc5052ac28ea3784eb02809
MD5 77c134d9787c08ffd0089e0788ee1c9c
BLAKE2b-256 584ef6604d5e684cee36911c5c32a70c9d7fd7af1bc6e98f118e192dff0bde46

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.4-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 629.2 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for smooth-1.0.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 1d0f7381446becf7eacc70c308328bbf351f0f815e654285319b9972ac76e67b
MD5 1bbca51ce604dfd397e63f606459c387
BLAKE2b-256 c19d0444547ed6bf90ee91e23611571e76a5e3a0626bfe4c64e094bfd709c57e

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp311-cp311-win_amd64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0b6380e3a414bd0494389307adf2ea6b7a6418ccfee8b1ff0afd26ed7957f751
MD5 d7fb5649f65af8f4cd1e667ba53586b1
BLAKE2b-256 cad4c94943299555f5cf04b107566f1b68db30c5c9c0c3644df2a8b3d81a7228

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0eddbe40ce2ca1dc3c67b1be18979b0ea1c6a3749908bc115dfe3555fea12643
MD5 48fba410f15b247eae15764f67ee40ad
BLAKE2b-256 ec1ef13faaab8a1b625de9c90b46212c2c01c7a7c32637e30444616700a28e03

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file smooth-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 715532720f23f9ac509c0e0a0c0f89b396bcb911036538ff76a7a897a2ae7450
MD5 9e2712c0cb6453747292a4420f4e1d99
BLAKE2b-256 c3e93636541f587153d0be1de55df765465351111ee8d0309e6c143178236be8

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.4-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: release.yml on config-i1/smooth

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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