This message was deleted.
# statsforecast
s
This message was deleted.
j
Hey. You can do something like this. For arima it'd be
[m.model_['arma'][i] for i in [0, 5, 1]]
(p, d, q)
a
@José Morales thanks ! As another question, how can we directly calculate a set of quantiles from the auto arima without using the level option in the predict function that returns intervals? I know we can derive quantiles from the intervals , but would be good to get the quantiles directly for evaluation via the crps
j
Do you mean when using conformal distribution?
a
Yes exactly
j
When you call fit with prediction_intervals we save the conformity scores in a
_cs
attribute of each model, which we later add and subtract to the forecasts to get the intervals (code). You can get these conformity scores for the first model after calling fit with the following:
Copy code
np.vstack([m._cs for m in sf.fitted_[:, 0]])
which is of shape (n_series * n_windows, horizon). Is that what you were looking for?
a
Can you please provide a reproducible example since the approaches you mention are not working. Thanks !
j
Sure, here it is:
Copy code
import numpy as np
from statsforecast import StatsForecast
from statsforecast.models import AutoARIMA
from statsforecast.utils import ConformalIntervals
from utilsforecast.data import generate_series

series = generate_series(2, freq='M', with_trend=True)
sf = StatsForecast(
    models=[AutoARIMA(season_length=12)],
    freq='M',
)
sf.fit(series, prediction_intervals=ConformalIntervals(h=5, n_windows=4))

orders = {uid: [m.model_['arma'][i] for i in [0, 5, 1, 2, 6, 3]] for uid, m in zip(sf.uids, sf.fitted_[:, 0])}  # these are (p, d, q, P, D, Q)
conformity_scores = np.vstack([m._cs for m in sf.fitted_[:, 0]])  # Array of shape (n_series * n_windows, horizon) where each value is abs(y_hat - y) in each of the windows
a
Thanks ! And how can I derive quantiles using your approach above ?
j
we save the conformity scores in a
_cs
attribute of each model, which we later add and subtract to the forecasts to get the intervals (code)
^ That's how we do it for the intervals. If you're looking to compute quantiles on the errors you can just do it directly on the scores
a
Ok many thanks !
s
Hi @José Morales - I'm trying to extract the order (p, d, q) and the seasonal order (P, D, Q) from trained autoArima models. Based on you're answer above, the order would be
model_['arma'][i] for i in [0, 5, 1]
. What's the correct ordering to get the seasonal order?
j
The seasonal is [2, 6, 3]. Note that you can also use the arima_string function to verify, e.g.
Copy code
from statsforecast.arima import arima_string
print(arima_string(arima_model))
s
got it - thank you!!