3

I am trying to extract the estimated (not predicted) values from the auto_arima model of the pmdarima library, I have not been able to. I have tried with:modl.fit() and it does not generate the values that later I need them to graph together with the training values len(train) = len(mod1.fit())

import pmdarima as pm
import matplotlib.pyplot as plt
import numpy as np


data = pm.datasets.load_lynx()
train, test = model_selection.train_test_split(data, train_size=90)

# Fit a simple auto_arima model
modl = pm.auto_arima(train, start_p=1, start_q=1, start_P=1, start_Q=1,
                     max_p=5, max_q=5, max_P=5, max_Q=5, seasonal=True,
                     stepwise=True, suppress_warnings=True, D=10, max_D=10,
                     error_action='ignore')

# ---- plot (train and fitted (yhat) values
plt.plot(train)
plt.plot(modl.fit())
plt.show()
royer
  • 615
  • 1
  • 6
  • 19

1 Answers1

3

I have doubts but here I present a supposed answer to my question and if it is not, please correct me:

Predicts the original training (in-sample) time series values. This can be useful when wanting to visualize the fit, and qualitatively inspect the efficacy of the model, or when wanting to compute the residuals of the model. reference

plt.plot(train)
plt.plot(modl.predict_in_sample() )
plt.show()

the function predict_in_sample() allows to extract the estimated values and in the case of R I suppose that it is modl$fit

royer
  • 615
  • 1
  • 6
  • 19