Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

auto_arima with out_of_sample_size provided returns np.array in prediction when pd.Series was given for estimation #559

Open
nvkost opened this issue Sep 4, 2023 · 0 comments

Comments

@nvkost
Copy link

nvkost commented Sep 4, 2023

Describe the bug

If the auto_arima is estimated with pd.Series it returns pd.Series from prediction (the same works for np.array). But when the auto_arima is estimated providing the out_of_sample_size parameter, it returns np.array from prediction independent of the object type used in estimation.

To Reproduce

#%%
import numpy as np
import pandas as pd

import pmdarima as pm

#%%
data = pm.datasets.load_lynx()

data_np = np.array(data)
data_pd = pd.Series(data)

#%%
model_np = pm.auto_arima(data_np)
model_pd = pm.auto_arima(data_pd)

# %%
print('np prediction', model_np.predict(1).__class__)
print('pd prediction', model_pd.predict(1).__class__)

# Output:
# np prediction <class 'numpy.ndarray'>
# pd prediction <class 'pandas.core.series.Series'>

# %%
modelx_np = pm.auto_arima(data_np, out_of_sample_size=1)
modelx_pd = pm.auto_arima(data_pd, out_of_sample_size=1)

# %%
print('np prediction with out_of_sample_size', modelx_np.predict(1).__class__)
print('pd prediction with out_of_sample_size', modelx_pd.predict(1).__class__)

# Output:
# np prediction with out_of_sample_size <class 'numpy.ndarray'>
# pd prediction with out_of_sample_size <class 'numpy.ndarray'>

Versions

System:
    python: 3.11.4 (main, Aug 21 2023, 21:32:39) [GCC 11.4.0]
executable: /home/unixuser/projects/pmdarima/.venv/bin/python
   machine: Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.35

Python dependencies:
 setuptools: 65.5.0
        pip: 23.2.1
    sklearn: 1.3.0
statsmodels: 0.14.0
      numpy: 1.25.2
      scipy: 1.11.2
     Cython: 3.0.2
     pandas: 2.1.0
     joblib: 1.3.2
   pmdarima: 0.0.0 # commit 1bb0ef5246c4e34712ef3e7843cf51a64b62bf0a
Linux-5.15.90.1-microsoft-standard-WSL2-x86_64-with-glibc2.35
Python 3.11.4 (main, Aug 21 2023, 21:32:39) [GCC 11.4.0]
pmdarima 0.0.0
NumPy 1.25.2
SciPy 1.11.2
Scikit-Learn 1.3.0
Statsmodels 0.14.0

Expected Behavior

It seems like the return type of prediction should not change due to the out_of_sample_size parameter.

Actual Behavior

The return type of prediction depends on the out_of_sample_size parameter of auto_arima.

Additional Context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant