Giter Site home page Giter Site logo

Comments (5)

tgsmith61591 avatar tgsmith61591 commented on June 30, 2024 2

I think it's very clear. The error is telling you two things:

  1. If you fit with exogenous, you must predict with exogenous
  2. When you are predicting with exogenous, your dimensions must match.

You need to follow the stack trace—why don't your dimensions match?

Because your test_number is 12, and the exogenous array you are providing corresponds to the training data (more than 12 samples). If you want to predict the next 12 values, you need to provide the corresponding 12 exogenous samples.

We are getting into the territory of me debugging your (unrelated) code. If we keep going down this route, I'm unfortunately going to have to lock the conversation to avoid spamming those who watch the mailing list.

from pmdarima.

tgsmith61591 avatar tgsmith61591 commented on June 30, 2024

I cannot replicate. Either you're not showing all your code or you're not showing all your data.

import numpy as np
import pyramid as pm

y = np.array([922.2, 0., 0., 0., 0., 0., 0., 9.9, 231.7, 1094.9, 2750.2, 4878.3])
xreg = np.array([28.2, 68.7, 57.7, 76.4, 98.4, 97.9, 63.1, 90.8, 72., 54.9, 77.6 ,61.3])\
         .reshape(y.shape[0], 1)

# This works (with warnings, admittedly)
pm.auto_arima(y, exogenous=xreg)

In the future, please provide your version of pyramid & statsmodels and don't attach images; put the code, data and stack trace inline (as I did) so it's easier to replicate.

from pmdarima.

Ashinhuang avatar Ashinhuang commented on June 30, 2024

OK,thanks sir, please let me recap my question

import numpy as np
from pyramid.arima import auto_arima

y = np.array([0, 0, 0, 0, 0, 176, 1048, 2235, 3220, 3946, 4361, 4382, 4226, 3791, 
              3059, 1990, 919, 161, 2, 0, 0, 0, 0, 0,  0, 0, 0, 0, 0, 139, 747, 
              1763, 2106, 2948, 2919, 3248, 3129, 2808, 1945, 1110, 709, 148, 
              3, 0, 0, 0, 0, 0])

exoge = np.array([0, 0, 0, 0, 19, 184, 474, 784, 992, 1174, 1315, 1267, 1121, 943, 
                 717, 406, 142, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 118, 412, 
                 487, 723, 797, 980, 905, 784, 768, 317, 298, 111, 9, 0, 0,
                 0, 0, 0, 0]).reshape(y.shape[0],1)

##the auto_arima
def trainAndTest(tsList,test_number=12):
    stepwise_fit = auto_arima(tsList,exogenous=None,start_p=1,max_p=1,start_q=1,max_q=1,m=12,
                          start_P=1,max_P=1,start_Q=1,max_Q=1, seasonal=True, d=1,D=1,trace=False,
                          error_action='ignore', suppress_warnings=True)
    pred = stepwise_fit.predict(test_number)
    return(pred)
    
pridict11 = trainAndTest(y, exogenous = exoge) 
# TypeError: trainAndTest() got an unexpected keyword argument 'exogenous'
predict = trainAndTest(y, exoge)   
#ValueError: When freq is None, you must give an integer index for end.

when run, pridict11 corresponding the error: TypeError: trainAndTest() got an unexpected keyword argument 'exogenous'
predict corresponding the error: ValueError: When freq is None, you must give an integer index for end.

very appreciate for your help ,Thanks very much!

from pmdarima.

tgsmith61591 avatar tgsmith61591 commented on June 30, 2024

Thanks for updating. Your first error is because you're passing a keyword (exogenous) to your function that does not exist. Also worth noting you're never passing the exogenous array into your auto_arima call as a result. Change your signature in your function call:

def trainAndTest(tsList, exogenous, test_number=12):
    stepwise_fit = auto_arima(tsList,exogenous=exogenous, ...)
   ...

The second error you're receiving is a result of you passing your exogenous array in place of an integer (which your function signature currently requires). Correct your function signature above, and this will be fixed.

Also worth noting if you fit a model with an exogenous array, you need an exogenous array for predictions (so you'll need to either not use an exogenous array, or pass another parameter test_exog that you might use in the predict call).

from pmdarima.

Ashinhuang avatar Ashinhuang commented on June 30, 2024

Thanks sir, but it's still not very clear
the modified function trainAndTest:

def trainAndTest(tsList,exogenous,test_number=12):
    stepwise_fit = auto_arima(tsList,exogenous=exogenous,start_p=1,max_p=1,start_q=1,max_q=1,m=12,
                          start_P=1,max_P=1,start_Q=1,max_Q=1, seasonal=True, d=1,D=1,trace=False,
                          error_action='ignore', suppress_warnings=True)
    pred = stepwise_fit.predict(test_number)
    return(pred)

pridict11 = trainAndTest(y, exogenous=exoge) 

#ValueError: When an ARIMA is fit with an exogenous array, 
#it must be provided one for predicting (either in- OR out-of-sample).

the error may be the predict lack of exogenous, but when I modify

pred = stepwise_fit.predict(test_number,exoge)

there is error that #ValueError: Exogenous array dims (n_rows) != n_periods
very appreciate for your help ,Thanks !

from pmdarima.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.