lavinei / pybats Goto Github PK
View Code? Open in Web Editor NEWBayesian time series forecasting and decision analysis
Home Page: https://lavinei.github.io/pybats/
License: Apache License 2.0
Bayesian time series forecasting and decision analysis
Home Page: https://lavinei.github.io/pybats/
License: Apache License 2.0
It seems that there is some issue with the plots. When I run the 1-day example in the docs, I found the graph attached. I think that the forecast and observation labels have been swapped (wrongly), isn't it? It is like the confindence interval has been plot for the observations.
In the docs the labels seem to be properly placed. What is the source of this difference? I am running exactly the same code.
It would be helpful if a reference to, or how, the define_glm_params (and the others) get their parameters.
For large prior_length the linear regression looks natural and the small size correction g/(1+g) is very close to 1, but I am not sure why g=int(n/2) (t-student moments suggest g=n).
Also, the returned "n" is - except the case of degeneracy in regressors - the number of degrees of freedom (number of observations minus the number of covariates) in the linear regression, while a naïve approach, applying a constant DLM model suggests the number of observations or that plus one.
If the reference are given, probably these objections are responded there.
When tested with the examples it works beautifully but whenever asked to forecast more data than available it doesn't do anything.
Am I missing something or should i use the generated model for that.
in other words, estimating X and call forecast modules for point and path forecasting.
Dear Isaac,
First off, I'm so glad this package exists and it has lots of cool features. I am currently looking at univariate count data with lots of zeroes and wanted to compare the Poisson DGLM forecasting performance with that of a DCMM. However, it seems that currently the analysis_dcmm function requires some input for the covariates X, and inputting None (like the default in the regular analysis function) throws an error of 'NoneType object not subscriptable'. I was able to 'monkey patch' a few of the functions in the package to get it to work for my case, but I think this is a capability that would probably be desirable for others.
I can create a reproducible example of the error if needed! Thanks!
Sincerely,
Brian
Hello, Lavinei,
I've decided to apply your approach to my own data and had no success with the error above:
/usr/local/lib/python3.6/dist-packages/pybats/dglm.py in simulate_from_sampling_model(self, p, nsamps)
415
416 def simulate_from_sampling_model(self, p, nsamps):
--> 417 return np.random.binomial(1, p, [nsamps])
418
419 def simulate_from_prior(self, alpha, beta, nsamps):
mtrand.pyx in numpy.random.mtrand.RandomState.binomial()
_common.pyx in numpy.random._common.check_array_constraint()
ValueError: p < 0, p > 1 or p contains NaNs
Link to the code: https://colab.research.google.com/drive/1_5LHVy1_EHRoohPhk8Dk26xTnVLooCRS?usp=sharing
I could send you the data by email, if it is possible.
Thanks!
Regards,
Nikita
Can you add negative binomial distribution in addition of poisson ?
Here, some
https://minimizeregret.com/post/2018/01/04/understanding-the-negative-binomial-distribution/
https://kth.diva-portal.org/smash/get/diva2:1249681/FULLTEXT01.pdf
thanks
Getting a ValueError: lam value too large
when building model using poisson distribution.
I have outlined the details in this SO question: https://stackoverflow.com/questions/68073589/pybats-forecast-error-when-using-poisson-family-distribution
Any assistance would be greatly appreciated! Thanks
Is it possible to use pybats to forecast with only univariate time series data? It seems like X needs to be populated when making a model. I was thinking that you could just put the time index or just put a lagged version of Y in for X.
Separately, I saw other questions asking how to forecast for Y_{t+k} given only information of X_{t}. It wasn't clear to me how you could do this without keeping a separate forecaster for X. It would be nice to be able to make forecasts without data until the next observation (usually when you get access to both X_{t+k} and Y_{t+k}.
I'm unable to generate a forecast_path
on a model with holiday regressors. The example below uses slightly modified code fro the order forecast example.
test_df = data.loc[forecast_start:forecast_end]
model = analysis(
train_df.Sales.values,
X=None,
family='poisson',
seasPeriods=[7],
seasHarmComponents=[[1,2,3]],
prior_length=prior_length,
dates=train_df.index,
holidays=USFederalHolidayCalendar.rules,
rho=rho,
ret = ['model']
)
model.forecast_path(k=10)
This results in the following error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-14-f1091b7e298d> in <module>
15 )
16
---> 17 model.forecast_path(k=10)
/jupyter/packages/pybats/dglm.py in forecast_path(self, k, X, nsamps, copula, phi_mu, phi_sigma, phi_psi, analytic, phi_samps, **kwargs)
287 else:
288 if copula:
--> 289 return forecast_path_copula(self, k, X, nsamps, **kwargs)
290 else:
291 return forecast_path(self, k, X, nsamps)
/jupyter/packages/pybats/forecast.py in forecast_path_copula(mod, k, X, nsamps, t_dist, y, nu, return_cov)
185 # Plug in the correct F values
186 if mod.nregn > 0:
--> 187 F = update_F(mod, X[i, :], F=F)
188 # if mod.nregn > 0:
189 # F[mod.iregn] = X[i,:].reshape(mod.nregn,1)
TypeError: 'NoneType' object is not subscriptable
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.