Skip to content

API Reference

Complete reference for all public classes and functions.


Models

All models follow the same interface:

model = ModelClass(**params)       # configure
model.fit(y, m=1, X=None)         # fit to data → returns self
fc = model.forecast(h=10, level=None)  # forecast → ForecastResult

Properties (after fitting)

Property Type Description
fitted_values np.ndarray In-sample fitted values
residuals np.ndarray In-sample residuals
summary str Model summary string
coefficients dict Model coefficients

Methods

Method Returns Description
.fit(y, m=1, X=None) self Fit model to data
.forecast(h=10, level=None) ForecastResult Generate forecasts
.predict(h=10, **kw) ForecastResult Alias for .forecast()
.get_params() dict Return model parameters

Exponential Smoothing

SES(initial="optimal", alpha=None, lambda_=None, biasadj=False)

Simple Exponential Smoothing. User Guide

Holt(damped=False, initial="optimal", exponential=False, alpha=None, beta=None, phi=None, lambda_=None, biasadj=False)

Holt's linear trend method. User Guide

HoltWinters(seasonal="additive", damped=False, initial="optimal", exponential=False, alpha=None, beta=None, gamma=None, phi=None, lambda_=None, biasadj=False)

Holt-Winters triple exponential smoothing. User Guide

ETS(model="ZZZ", damped=None, alpha=None, beta=None, gamma=None, phi=None, additive_only=False, lambda_=None, biasadj=False, opt_crit="lik", ic="aicc", bounds="both", restrict=True, allow_multiplicative_trend=False)

Error-Trend-Seasonal state space model. User Guide

Croston()

Simple Croston method for intermittent demand. User Guide


ARIMA

ARIMA(order=(0,0,0), seasonal_order=None, include_mean=True, method="CSS-ML", transform_pars=True, lambda_=None, biasadj=None)

ARIMA/SARIMA model. User Guide

AutoARIMA(d=None, D=None, max_p=5, max_q=5, max_P=2, max_Q=2, max_order=5, max_d=2, max_D=1, stationary=False, seasonal=True, stepwise=True, trace=False, approximation=True, ic="aicc", test="adf", seasonal_test="ocsb", allowmean=True, allowdrift=True, lambda_=None, biasadj=None)

Automatic ARIMA selection. User Guide


Naive Methods

Naive(lambda_=None, biasadj=False)

Naive forecast (last value). User Guide

SeasonalNaive(lambda_=None, biasadj=False)

Seasonal naive forecast. User Guide

RandomWalk(drift=False, lambda_=None, biasadj=False)

Random walk with optional drift. User Guide

MeanForecast(lambda_=None, biasadj=False)

Mean forecast. User Guide


BATS / TBATS

BATS(use_box_cox=None, use_trend=None, use_damped_trend=None, use_arma_errors=True, bc_lower=0.0, bc_upper=1.0, biasadj=False)

BATS model for complex seasonality. User Guide

TBATS(use_box_cox=None, use_trend=None, use_damped_trend=None, use_arma_errors=True, bc_lower=0.0, bc_upper=1.0, biasadj=False)

Trigonometric BATS for non-integer periods. User Guide


Theta

Theta(model_type="OTM", alpha=None, theta_param=None, initial_level=None, nmse=3)

Theta method. User Guide

AutoTheta(model=None, decomposition_type="multiplicative", alpha=None, theta_param=None, initial_level=None, nmse=3)

Automatic Theta selection. User Guide


Diffusion

Diffusion(model_type="Bass", cleanlead=True, loss=2, cumulative=True)

Innovation diffusion model. User Guide


ARAR / ARARMA

ARAR(max_ar_depth=None, max_lag=None)

ARAR model. User Guide

ARARMA(max_ar_depth=26, max_lag=40, p=4, q=1)

ARARMA model. User Guide

AutoARARMA(min_p=0, max_p=4, min_q=0, max_q=2, max_ar_depth=26, max_lag=40)

Automatic ARARMA selection. User Guide


Intermittent Demand

CrostonClassic(init_strategy="mean", number_of_params=2, cost_metric="mar", optimize_init=True, rm_missing=False)

Croston's classic method. User Guide

CrostonSBA(...)

Syntetos-Boylan Approximation. Same parameters as CrostonClassic. User Guide

CrostonSBJ(...)

Shale-Boylan-Johnston variant. Same parameters as CrostonClassic. User Guide


ForecastResult

@dataclass
class ForecastResult:
    mean: np.ndarray              # point forecasts
    lower: dict[int, np.ndarray]  # {80: [...], 95: [...]}
    upper: dict[int, np.ndarray]  # {80: [...], 95: [...]}
    level: list[int]              # [80, 95]
    fitted_values: np.ndarray     # in-sample fitted
    residuals: np.ndarray         # in-sample residuals
    method: str                   # model description
    x: np.ndarray                 # original data

Methods

Method Returns Description
.to_dataframe() pd.DataFrame Columns: step, mean, lower_80, upper_80, ...
.plot(ax=None, show_history=True) matplotlib Axes Plot forecast with intervals

compare()

compare(
    models: dict[str, BaseForecaster],
    y_train: array-like,
    y_test: array-like,
    m: int = 1,
    h: int | None = None,
    level: list[int] | None = None,
) -> ComparisonResult

User Guide


ComparisonResult

Attribute Type Description
model_names list[str] Model names
forecasts dict[str, ForecastResult] Forecasts per model
metrics dict[str, dict[str, float]] Metrics per model
Method Returns Description
.to_dataframe() pd.DataFrame One row per model, metric columns
.plot(ax=None) matplotlib Axes Overlay all forecasts

PanelForecaster

PanelForecaster(model: BaseForecaster, groupby: str | list[str])
Method Returns Description
.fit(data, y_col="y", m=1, date_col=None) self Fit per group
.forecast(h=10, level=None) PanelForecastResult Forecast all groups

User Guide


PanelForecastResult

Attribute Type Description
groups dict[Any, ForecastResult] Results per group
Method Returns Description
.to_dataframe() pd.DataFrame Long-format with group column

Metrics

from durbyn.metrics import me, rmse, mae, mpe, mape, mase, acf1, accuracy
Function Signature Description
me(actual, predicted) → float Mean Error
rmse(actual, predicted) → float Root Mean Squared Error
mae(actual, predicted) → float Mean Absolute Error
mpe(actual, predicted) → float Mean Percentage Error (%)
mape(actual, predicted) → float Mean Absolute Percentage Error (%)
mase(actual, predicted, training_data) → float Mean Absolute Scaled Error
acf1(actual, predicted) → float Lag-1 autocorrelation of errors
accuracy(actual, predicted, training_data=None) → dict All metrics combined

User Guide


Exceptions

from durbyn.exceptions import DurbynError, NotFittedError, JuliaNotAvailableError, DurbynNotInstalledError
Exception Parent Description
DurbynError Exception Base exception
JuliaNotAvailableError DurbynError, ImportError Julia runtime not found
DurbynNotInstalledError DurbynError, ImportError Durbyn.jl not installed
NotFittedError DurbynError, RuntimeError Model not fitted yet