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 SLSA Build Level 3 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.

Every wheel published to PyPI is signed via Sigstore on the exact GitHub Actions runner that built it and ships with PEP 740 attestations (SLSA Build Level 3 provenance). Verify a downloaded wheel client-side with pypi-attestations:

pip install pypi-attestations
pypi-attestations verify pypi --repository https://github.com/config-i1/smooth smooth-*.whl

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.
  • CES - Complex Exponential Smoothing with complex-valued smoothing parameters, implemented in the CES class (fixed seasonality type) and AutoCES class (automatic seasonality selection).
  • 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.

The package also provides standalone data generators that mirror R's sim.* family — sim_es, sim_ssarima, sim_ces, sim_gum, sim_sma, and sim_oes — plus a .simulate() method on fitted ADAM, OM, and OMG objects. See Simulation Functions.

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)

CES — Complex Exponential Smoothing

CES and AutoCES mirror R's ces() / auto.ces(). CES uses complex-valued smoothing parameters to capture both the level and the "potential" of a series, covering four seasonality modes: "none", "simple", "partial", "full".

import numpy as np
from smooth import CES, AutoCES

y = np.array([
    112, 118, 132, 129, 121, 135, 148, 148, 136, 119, 104, 118,
    115, 126, 141, 135, 125, 149, 170, 170, 158, 133, 114, 140,
], dtype=float)

# CES with a fixed seasonality type
model = CES(seasonality="partial", lags=[1, 12], h=6, holdout=True)
model.fit(y)
print(model.model_name)         # e.g. "CES(partial)"
print(model.a_, model.b_)       # complex smoothing parameters
fc = model.predict(h=6)
print(fc.mean)

# AutoCES — select the best seasonality type by information criterion
auto = AutoCES(lags=[1, 12], h=6, holdout=True, ic="AICc")
auto.fit(y)
print(auto.best_model_.model_name)

Note: strict R-parity in the two-stage NLopt path requires nlopt>=2.10.0; older versions still fit, but the BOBYQA stage-1 trajectory may differ slightly from R.

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
  • CES — Complex Exponential Smoothing (CES, AutoCES)
  • 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
  • Simulation Functionssim_es, sim_ssarima, sim_ces, sim_gum, sim_sma, sim_oes, and the .simulate() method on fitted models

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.6.tar.gz (12.1 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.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.8 MB view details)

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

smooth-1.0.6-cp313-cp313-win_amd64.whl (13.7 MB view details)

Uploaded CPython 3.13Windows x86-64

smooth-1.0.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.8 MB view details)

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

smooth-1.0.6-cp313-cp313-macosx_11_0_arm64.whl (759.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

smooth-1.0.6-cp313-cp313-macosx_10_13_x86_64.whl (796.0 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

smooth-1.0.6-cp312-cp312-win_amd64.whl (13.7 MB view details)

Uploaded CPython 3.12Windows x86-64

smooth-1.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.8 MB view details)

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

smooth-1.0.6-cp312-cp312-macosx_11_0_arm64.whl (759.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

smooth-1.0.6-cp312-cp312-macosx_10_13_x86_64.whl (796.0 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

smooth-1.0.6-cp311-cp311-win_amd64.whl (13.7 MB view details)

Uploaded CPython 3.11Windows x86-64

smooth-1.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (12.8 MB view details)

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

smooth-1.0.6-cp311-cp311-macosx_11_0_arm64.whl (761.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

smooth-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl (795.3 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: smooth-1.0.6.tar.gz
  • Upload date:
  • Size: 12.1 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.6.tar.gz
Algorithm Hash digest
SHA256 62f8348ee164b65b396df80fd270135f8e7b74de3f2e009fe20c332ae82f2205
MD5 98ff7b66387be71092f4e4db4c03580d
BLAKE2b-256 0ad7c98fbda811d3ba5566e7c8844731ed4b2d3479dd9106f7370804e835da22

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6.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.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp314-cp314-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 dd97c160459b341aa3ba23f077ee66d36a70ea815f54ccebdfb74acd52311e73
MD5 93f7a1e3d428db815c5c43a5a48de0d0
BLAKE2b-256 569cd133364615e4ba8d4f9ebd35a4dfd2690a214392ba4ad8d34405f0c351da

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 13.7 MB
  • 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 101d3f054227c8b8c53c28aea16025594137bd8b49effee205a64e15d8d8a7c3
MD5 e1701c76f4430991c1c03fa98667616e
BLAKE2b-256 b4526b74ccb2cb7cc051d74658572d64e3af1cdeee7a07dd8ca811032d7d79a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a2fbf3567726a07129f0de97b7fef4452e32852271ac431d8b2802acc20e034
MD5 e9e889f4c940e104f30284abb9c9c697
BLAKE2b-256 3eaefcc38707eaa9e17d3ac308a81bdcdf202dea41a1210eba7d97e83a7a35e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 962142cd8931242698ece329208e416b8c6b87038f3e72281a0e2175417c16fe
MD5 3a4cd55715ec86bd537e5d452865f774
BLAKE2b-256 8b4ec44bbb12b148ffac17a1eee813ab324fd60c0189eec264ee0d38d8d6defc

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 e334dab69d8d59ea2189de37c6a2083d3ded2fd8ef83c45e7c3ca77c357dbf8a
MD5 5d879c53223d2bbc3030e846d034c558
BLAKE2b-256 4bc1c164098eea73149edc65beae994b2013f0cbcc8fcc02bee4206fbf090b45

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 13.7 MB
  • 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ff330d5b8838c0d6a58de6be36aa01025469df2fa0b00db5dc9cdeb6ba74067c
MD5 6d60528d379e47dc262d8cec14c5592f
BLAKE2b-256 af6502e0f69d8b66f984d60bfde1228d526ea6563fc968e65d74bc4f0cb8a885

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5844ecbe700b750cb1ed523fc580967bb6a7294691a958585340daa2c138bf68
MD5 8bab206cc8a56c8c6c4d708d905c7327
BLAKE2b-256 0e38ffc5737dc50711cc97631190732ee8da75c535a439a79706dfd99851bbdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2a8686b51d7ded0b0d676619b06165c0b14d3db4efe12ea3b4f213b29cc199bd
MD5 28723dcfdf1ef383eec0c55c44a966aa
BLAKE2b-256 6fee4ddd41a38b875ae938b5f0cd530dc3cdaabc2af94a8a3e148df915946af7

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 f0a97105b6ee0baa4205a7edd38f3adb61ebca1a085f80e72083bb83393652e5
MD5 80869e55ba5e99ddfe4d1163ba9e9785
BLAKE2b-256 307e8f1a1674b08a3c15bd7b8cbf1a766cbba327496f5e038477e94e07aa1d9b

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: smooth-1.0.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 13.7 MB
  • 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 22f7042cdf4af93eeb436628e1f121c0ec7ccc48f04e32f44482d057b85c2de4
MD5 8a2c0589f84f39b01d9a96a7d821ac3d
BLAKE2b-256 bb7bdc7589c7af3190031093972e3ad996397b81a0617f0f3ba1972afce3ea3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 da2548bda73eb5c99fee0ecc11fbce2e076cd30eb9422de5602382c2d23571a1
MD5 16dab1be07fb3cb21a16b1f5c6c57f03
BLAKE2b-256 4d59e9aaec6a1f12f901474640505ca2da6029900463e4353467bb4d45e237e6

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5cdffbc5bbb686efe9c33ca40a993b1cc8796b23a8126748e7d61e1acb82d77e
MD5 824845c92ceba172522c0b13b8f18f84
BLAKE2b-256 fc54a1e6d16d7e518bdee2bc32fbe5d859f870a54065530a79691bfa6674dd26

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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.6-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for smooth-1.0.6-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3c8e923a377a6c78e975ce8053c7bcee8fa0f1d68eb302e06649034b49f0a4de
MD5 86c4233dcee10d5f5a2a65349a81e196
BLAKE2b-256 76595719a61c3801e6f47fea046751c20480eff04ab23fdb2997fd28ef8368be

See more details on using hashes here.

Provenance

The following attestation bundles were made for smooth-1.0.6-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