OM, OMG and AutoOM

Occurrence models for intermittent demand forecasting.

OM

class smooth.OM(model='ZXZ', lags=None, ar_order=0, i_order=0, ma_order=0, orders=None, constant=False, formula=None, regressors='use', occurrence='odds-ratio', loss='likelihood', h=0, holdout=False, persistence=None, phi=None, initial='backcasting', n_iterations=None, arma=None, ic='AICc', bounds='usual', verbose=0, nlopt_kargs=None, ets='conventional', **kwargs)

Occurrence model — Python port of R’s om().

Inherits the ADAM API surface and overrides the bits that differ: cost function (Bernoulli likelihood with link transform), distribution (always "plogis"), scale (nan), and model-name format ("oETS(...)[F|O|I|D]").

OM fits a single-component occurrence model to a binary demand-occurrence series. The occurrence type ("fixed", "logistic", "odds-ratio", "inverse-odds-ratio", "general") can be set explicitly or selected automatically with occurrence="auto". When occurrence="auto", .fit() returns the best OM or OMG instance directly.

from smooth import OM
import numpy as np

# Binary occurrence series (1 = demand observed, 0 = zero demand)
y = np.array([0, 1, 0, 0, 1, 1, 0, 1] * 10, dtype=float)

# Explicit occurrence type
model = OM(model="ANN", occurrence="logistic", lags=[1])
model.fit(y)
print(model)

# Automatic type selection — returns best OM or OMG
best = OM(model="ANN", occurrence="auto", lags=[1]).fit(y)
print(best.occurrence)
fc = best.predict(h=8)

OMG

class smooth.OMG(model_a='MNN', model_b=None, lags=None, orders_a=None, orders_b=None, constant_a=False, constant_b=None, formula_a=None, formula_b=None, regressors_a='use', regressors_b=None, persistence_a=None, persistence_b=None, phi_a=None, phi_b=None, arma_a=None, arma_b=None, h=0, holdout=False, initial='backcasting', loss='likelihood', ic='AICc', bounds='usual', verbose=0, nlopt_kargs=None, ets='conventional')

General occurrence model — two parallel ETS sub-models combined.

Public API:

fit(y, X=None) → self predict(h, X=None)ForecastResult

Attributes after fit:

model_a : OM — odds-ratio sub-model model_b : OM — inverse-odds-ratio sub-model fitted : combined probabilities ∈ (0, 1) residuals : ot - fitted loss_value, loglik, aic/aicc/bic/bicc coef : joint parameter vector concat(B_A, B_B) model_name : "oETS[G](MNN)(MNN)"-style string

OMG is the general two-component occurrence model with separate A-side and B-side ETS models. It is more flexible than a single OM but requires more data to estimate reliably.

from smooth import OMG

model = OMG(model="ANN", lags=[1])
model.fit(y)
print(model)

fc = model.predict(h=8)
print(fc.mean)

# Access component diagnostics
print(model.fitted)
print(model.b_value)

AutoOM

class smooth.AutoOM(model='ZXZ', lags=None, orders=None, occurrence=['fixed', 'odds-ratio', 'inverse-odds-ratio', 'direct', 'general'], h=0, holdout=False, persistence=None, phi=None, initial='backcasting', constant=False, arma=None, regressors='use', ic='AICc', bounds='usual', verbose=0, nlopt_kargs=None, ets='conventional')

Automatic occurrence model selection — port of R’s auto.om().

Fits an OM (or OMG) for each entry in occurrence and returns the best-fitting model (lowest IC) directly. The returned object is a plain OM or OMG with one extra attribute time_elapsed_ (total selection time in seconds), matching R’s $timeElapsed on the returned om object.

Parameters:
  • model (str) – ETS spec passed to every candidate, including both sub-models of the general (OMG) candidate.

  • lags (Optional[List[int]]) – Seasonal lags shared across all candidates.

  • orders (Optional[Dict[str, Any]]) – ARIMA orders forwarded to every candidate.

  • occurrence (Union[List[str], str]) – Sequence of occurrence types to try.

  • h (int) – Forecast horizon and holdout flag forwarded to every candidate.

  • holdout (bool) – Forecast horizon and holdout flag forwarded to every candidate.

  • ic (Literal['AIC', 'AICc', 'BIC', 'BICc']) – Information criterion used for selection.

AutoOM tests multiple occurrence types and returns the best OM or OMG instance, selected by information criterion (default: AICc). It is the Python equivalent of R’s auto.om().

from smooth import AutoOM

# Test a subset of occurrence types
model = AutoOM(model="ANN", lags=[1],
               occurrence=["logistic", "odds-ratio", "general"])
best = model.fit(y)
print(best.occurrence)    # e.g. "odds-ratio"
print(best.model_name)

# Default: all supported types
best = AutoOM(model="ANN", lags=[1]).fit(y)
fc = best.predict(h=8)

See Also

  • ADAM — Full ETS + ARIMA model (the demand-size component)

  • AutoADAM — Automatic ETS + distribution + ARIMA selection

  • AutoMSARIMA — Automatic pure-ARIMA selection