RJT1990 / pyflux

Open source time series library for Python
BSD 3-Clause "New" or "Revised" License
2.1k stars 240 forks source link

ARIMAX.predict error #92

Closed ghost closed 6 years ago

ghost commented 7 years ago

Hi,

I faced with some error when using the ARIMAX.predict().

The ARIMAX example in documentation seems to train the whole model on OOS data. My problem is I need to predict future value based on current exogenous variables. Below is my dummy code:

# train the model
data = pd.DataFrame(dict(x=[45, 50, 55, 60, 70, 80, 90]))
data['y'] = 0.5 + data['x'] + scipy.stats.norm.rvs(scale=2, size=data.shape[0])
model = pf.ARIMAX(data=data, formula='y~1+x',ar=1, ma=0, family=pf.Normal())
model.fit("MLE")

data_new = pd.DataFrame(dict(x=[100, 120], y=[np.nan, np.nan]))
model.predict(h=2, oos_data=data_new)

The model was trained successfully, but when it came to predict, it just raised the Exception, IndexError: index 0 is out of bounds for axis 0 with size 0.

Can anyone help me to find the correct way to use predict()? Do I need to assign the index of the oos_data?

RJT1990 commented 6 years ago

Thanks, I am looking at this now.

RJT1990 commented 6 years ago

The issue is with the nans in the oos_data column. I am pushing a fix for this tonight.