--- title: Models keywords: fastai sidebar: home_sidebar summary: "Uniserie models implementations." description: "Uniserie models implementations." nb_path: "nbs/models.ipynb" ---
{% raw %}
/home/jose/mambaforge/envs/statsforecast/lib/python3.9/site-packages/statsmodels/compat/pandas.py:65: FutureWarning: pandas.Int64Index is deprecated and will be removed from pandas in a future version. Use pandas.Index with the appropriate dtype instead.
  from pandas import Int64Index as NumericIndex
{% endraw %} {% raw %}
{% endraw %} {% raw %}

ses[source]

ses(X, h, future_xreg, alpha)

{% endraw %} {% raw %}

adida[source]

adida(X, h, future_xreg)

{% endraw %} {% raw %}

historic_average[source]

historic_average(X, h, future_xreg)

{% endraw %} {% raw %}

croston_classic[source]

croston_classic(X, h, future_xreg)

{% endraw %} {% raw %}

croston_sba[source]

croston_sba(X, h, future_xreg)

{% endraw %} {% raw %}

croston_optimized[source]

croston_optimized(X, h, future_xreg)

{% endraw %} {% raw %}

seasonal_window_average[source]

seasonal_window_average(X:ndarray, h:int, future_xreg, season_length:int, window_size:int)

{% endraw %} {% raw %}

seasonal_naive[source]

seasonal_naive(X, h, future_xreg, season_length)

{% endraw %} {% raw %}

imapa[source]

imapa(X, h, future_xreg)

{% endraw %} {% raw %}

naive[source]

naive(X, h, future_xreg)

{% endraw %} {% raw %}

random_walk_with_drift[source]

random_walk_with_drift(X, h, future_xreg)

{% endraw %} {% raw %}

window_average[source]

window_average(X, h, future_xreg, window_size)

{% endraw %} {% raw %}

seasonal_exponential_smoothing[source]

seasonal_exponential_smoothing(X, h, future_xreg, season_length, alpha)

{% endraw %} {% raw %}

tsb[source]

tsb(X, h, future_xreg, alpha_d, alpha_p)

{% endraw %} {% raw %}
{% endraw %} {% raw %}

auto_arima[source]

auto_arima(X:ndarray, h:int, future_xreg=None, season_length:int=1, approximation:bool=False, level:Optional[Tuple[int]]=None)

{% endraw %} {% raw %}
{% endraw %} {% raw %}
from statsforecast.utils import AirPassengers as ap
{% endraw %} {% raw %}
auto_arima(ap, 12, season_length=12)
array([444.30005077, 418.2100203 , 446.23703401, 488.22892853,
       499.23136059, 562.23063085, 649.23084981, 633.23078411,
       535.23080382, 488.23079791, 417.23079968, 459.23079915])
{% endraw %}

External regressors

{% raw %}
drift = np.arange(1, ap.size + 1)
X = np.vstack([ap, np.log(drift), np.sqrt(drift)]).T
{% endraw %} {% raw %}
newdrift = np.arange(ap.size + 1, ap.size + 7 + 1).reshape(-1, 1)
newxreg = np.concatenate([np.log(newdrift), np.sqrt(newdrift)], axis=1)
{% endraw %} {% raw %}
auto_arima(X, 7, future_xreg=newxreg, season_length=12)
array([444.37994435, 418.3426712 , 446.43052379, 488.47985218,
       499.54005383, 562.59623451, 649.65290106])
{% endraw %}

Confidence intervals

{% raw %}
pd.DataFrame(auto_arima(ap, 12, season_length=12, level=(80, 95)))
mean lo-80 lo-95 hi-80 hi-95
0 444.300051 429.182317 421.179472 459.417784 467.420629
1 418.210020 399.756915 389.988431 436.663126 446.431610
2 446.237034 424.256469 412.620660 468.217599 479.853408
3 488.228929 463.405840 450.265291 513.052017 526.192566
4 499.231361 471.807503 457.290190 526.655218 541.172531
5 562.230631 532.446502 516.679736 592.014760 607.781525
6 649.230850 617.256215 600.329866 681.205484 698.131833
7 633.230784 599.207510 581.196677 667.254058 685.264891
8 535.230804 499.275106 480.241310 571.186501 590.220298
9 488.230798 450.441457 430.436989 526.020138 546.024607
10 417.230800 377.692737 356.762551 456.768863 477.699049
11 459.230799 418.018156 396.201501 500.443442 522.260098
{% endraw %}