wwrechard / pydlm

A python library for Bayesian time series modeling
BSD 3-Clause "New" or "Revised" License
475 stars 98 forks source link

forecast with regressors #38

Open tyokota opened 5 years ago

tyokota commented 5 years ago

Is it possible to forecast with regressors such as in the Google example? I first split the data into a train and valid set. I fit the train set. Then I conform the valid set regressors into a dictionary as such:

new_dict = {k:list(df[k].unique()) for k in df.columns}

However, I am seeing a NameError: The step is out of range error.

wwrechard commented 4 years ago

Yes, it's possible, but you need to supply the data to the regressor before making prediction. The out of range error is caused by insufficient data in the regressor.

May I know how you supply the new features into the model? One way to do is via predictN and featureDict: https://github.com/wwrechard/pydlm/blob/a2bbfd97fb9285d131a6a8be82e0728ff2d4f567/pydlm/predict/dlmPredictMod.py#L86

logisticregress commented 4 years ago

I'm having the same issue.
I have one predictor, and I'm trying to forecast out 3 days, so I've newf = {'x2':[[-0.13064217],[-0.13064217],[-0.13064217]]}

(predictMean, predicrVar) = drm.predictN(N=3,date=drm.n-1, featureDict=newf)

NameError: The step is out of range

I'm not sure what I'm doing wrong in setting up the future values of the predictor variable.

Jill07217 commented 4 years ago

Same here.

I try to output 12 months ahead (N=12) with the featureDict having 12 dynamic components. But I still get the NameError: The step is out of range. Could you please provide any insights?

ramdhan1989 commented 3 years ago

same here. I am confused to use featuredict. any example of using this will be good