Comments (5)
I think it's very clear. The error is telling you two things:
- If you fit with exogenous, you must predict with exogenous
- 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.
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.
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.
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.
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)
- pmdarima negative forecasts HOT 1
- Is endog_index_ attribute of a model intended to update?
- FourierFeaturizer and DateFeaturizer pipeline: "transform() got multiple values for argument 'y' result" HOT 6
- Pipeline does not work when using FourierFeaturizer in colab HOT 1
- Update ARIMA model without changing model coefficients
- numpy 1.24.2 and pmdarima 2.0.3 incompatibility HOT 2
- No module named 'pkg_resources' HOT 2
- "ValueWarning: No supported index is available. Prediction results will be given with an integer index beginning at `start`. return get_prediction_index("
- Minimum orders in auto_arima HOT 2
- Stepwise selection of exogenous features HOT 1
- LU decomposition error raised when run wine sample
- auto_arima with missing values
- Better explanation of error
- boxcox cannot de-exponentiate in a pipeline.
- auto_arima with out_of_sample_size provided returns np.array in prediction when pd.Series was given for estimation
- Can´t import pmdarima HOT 2
- Cannot install package pmdarima through pip HOT 3
- Failed to install pmdarima in Python 3.12 HOT 2
- Save search steps and metrics output on auto_arima
- predict_in_sample with exogenous variables
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pmdarima.