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

ValueError When replicating the Quickstart example using wineind dataset #461

Closed
pmoriano opened this issue Oct 12, 2021 · 3 comments
Closed

Comments

@pmoriano
Copy link

pmoriano commented Oct 12, 2021

Hello,
Thanks for putting together this amazing package. I am trying to replicate one of the basic examples in the documentation. See below:

import pmdarima as pm
from pmdarima.model_selection import train_test_split
import numpy as np
import matplotlib.pyplot as plt

# Load/split your data
y = pm.datasets.load_wineind()
train, test = train_test_split(y, train_size=150)

# Fit your model
model = pm.auto_arima(train, seasonal=True, m=12)

However, when building the model (last line) I am getting the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_228524/3922284263.py in <module>
      3 
      4 # Fit model
----> 5 model = pm.auto_arima(train, seasonal=True, m=12)
      6 
      7 # forecasts = model.predict(test.shape[0])

~/.conda/envs/basic38/lib/python3.8/site-packages/pmdarima/arima/auto.py in auto_arima(y, X, start_p, d, start_q, max_p, max_d, max_q, start_P, D, start_Q, max_P, max_D, max_Q, max_order, m, seasonal, stationary, information_criterion, alpha, test, seasonal_test, stepwise, n_jobs, start_params, trend, method, maxiter, offset_test_args, seasonal_test_args, suppress_warnings, error_action, trace, random, random_state, n_fits, return_valid_fits, out_of_sample_size, scoring, scoring_args, with_intercept, sarimax_kwargs, **fit_args)
    715         )
    716 
--> 717     sorted_res = search.solve()
    718     return _return_wrapper(sorted_res, return_valid_fits, start, trace)
    719 

~/.conda/envs/basic38/lib/python3.8/site-packages/pmdarima/arima/_auto_solvers.py in solve(self)
    284 
    285         # fit a baseline p, d, q model
--> 286         self._do_fit((p, d, q), (P, D, Q, m))
    287 
    288         # null model with possible constant

~/.conda/envs/basic38/lib/python3.8/site-packages/pmdarima/arima/_auto_solvers.py in _do_fit(self, order, seasonal_order, constant)
    231             self.k += 1
    232 
--> 233             fit, fit_time, new_ic = self._fit_arima(
    234                 order=order,
    235                 seasonal_order=seasonal_order,

~/.conda/envs/basic38/lib/python3.8/site-packages/pmdarima/arima/_auto_solvers.py in _fit_candidate_model(y, X, order, seasonal_order, start_params, trend, method, maxiter, fit_params, suppress_warnings, trace, error_action, out_of_sample_size, scoring, scoring_args, with_intercept, information_criterion, **kwargs)
    528         # check the roots of the new model, and set IC to inf if the
    529         # roots are near non-invertible
--> 530         ic = _root_test(fit, ic, trace)
    531 
    532     # log the model fit

~/.conda/envs/basic38/lib/python3.8/site-packages/pmdarima/arima/_auto_solvers.py in _root_test(model, ic, trace)
     36 
     37     if p + P > 0:
---> 38         max_invroot = max(0, *np.abs(1 / model.arroots()))
     39     if q + Q > 0 and np.isfinite(ic):
     40         max_invroot = max(0, *np.abs(1 / model.maroots()))

~/.conda/envs/basic38/lib/python3.8/site-packages/sklearn/utils/metaestimators.py in __get__(self, obj, owner)
    107             # delegate only on instances, not the classes.
    108             # this is to allow access to the docstrings.
--> 109             if not self.check(obj):
    110                 raise attr_err
    111 

~/.conda/envs/basic38/lib/python3.8/site-packages/sklearn/utils/metaestimators.py in _check(self, obj)
    195             return False
    196         # raise original AttributeError
--> 197         return getattr(delegate, self.attribute_name) or True
    198 
    199 

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

I have no clue of what is the issue. I am running this in Linux with miniconda environment. I would appreciate any pointers. I installed pmdarima following instructions in the documentation for conda.

Thanks in advance.

@tgsmith61591
Copy link
Member

tgsmith61591 commented Oct 12, 2021

I'm guessing you're running pmdarima 1.8.2. Can you upgrade to 1.8.3? Sklearn shipped a version that broke our dependency on them and it was recently fixed in #455

If that does not solve the issue, please feel free to reopen.

@aaronreidsmith
Copy link
Member

aaronreidsmith commented Oct 12, 2021

If you installed via conda, then you may need to downgrade your scikit-learn version, as 1.8.3 is not available on conda yet (follow this PR to see when it will be available).

Try this:

conda install -c conda-forge scikit-learn=0.24.2

@pmoriano
Copy link
Author

@tgsmith61591 and @aaronreidsmith. Thanks for your help. Doing what you suggested works.

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

No branches or pull requests

3 participants