pymc3

Custom Theano Op to do numerical integration

一个人想着一个人 提交于 2019-12-01 04:09:53
问题 I'm attempting to write a custom Theano Op which numerically integrates a function between two values. The Op is a custom likelihood for PyMC3 which involves the numerical evaluation of some integrals. I can't simply use the @as_op decorator as I need to use HMC to do the MCMC step. Any help would be much appreciated, as this question seems to have come up several times but has never been solved (e.g. https://stackoverflow.com/questions/36853015/using-theano-with-numerical-integration, Theano

Modified BPMF in PyMC3 using `LKJCorr` priors: PositiveDefiniteError using `NUTS`

给你一囗甜甜゛ 提交于 2019-12-01 03:06:57
问题 I previously implemented the original Bayesian Probabilistic Matrix Factorization (BPMF) model in pymc3 . See my previous question for reference, data source, and problem setup. Per the answer to that question from @twiecki, I've implemented a variation of the model using LKJCorr priors for the correlation matrices and uniform priors for the standard deviations. In the original model, the covariance matrices are drawn from Wishart distributions, but due to current limitations of pymc3 , the

Custom likelihood in pymc3

痴心易碎 提交于 2019-11-30 14:06:27
How can I define a custom likelihood in PyMC3? In PyMC2, I could use @pymc.potential . I tried to use pymc.Potential in PyMC3, however, it seems that boolean operations cannot be applied to the parameters (I get an error like this when I do that). For example, following code does not work: from pymc import * with Model() as model: x = Normal('x', 1, 1) def z(u): if u > 0: #comparisons like this are not supported # if theano.tensor.lt(0,u): this is how comparison should be done return u ** 2 return -u**3 x2 = Potential('x2', z(x)) start = model.test_point h = find_hessian(start) step =

Generating predictions from inferred parameters in pymc3

余生长醉 提交于 2019-11-30 06:37:25
I run into a common problem I'm wondering if someone can help with. I often would like to use pymc3 in two modes: training (i.e. actually running inference on parameters) and evaluation (i.e. using inferred parameters to generate predictions). In general, I'd like a posterior over predictions, not just point-wise estimates (that's part of the benefit of the Bayesian framework, no?). When your training data is fixed, this is typically accomplished by adding simulated variable of a similar form to the observed variable. For example, from pymc3 import * with basic_model: # Priors for unknown

pymc3 : Multiple observed values

夙愿已清 提交于 2019-11-30 00:56:35
I have some observational data for which I would like to estimate parameters, and I thought it would be a good opportunity to try out PYMC3. My data is structured as a series of records. Each record contains a pair of observations that relate to a fixed one hour period. One observation is the total number of events that occur during the given hour. The other observation is the number of successes within that time period. So, for example, a data point might specify that in a given 1 hour period, there were 1000 events in total, and that of those 1000, 100 were successes. In another time period,

Generating predictions from inferred parameters in pymc3

倖福魔咒の 提交于 2019-11-29 06:14:36
问题 I run into a common problem I'm wondering if someone can help with. I often would like to use pymc3 in two modes: training (i.e. actually running inference on parameters) and evaluation (i.e. using inferred parameters to generate predictions). In general, I'd like a posterior over predictions, not just point-wise estimates (that's part of the benefit of the Bayesian framework, no?). When your training data is fixed, this is typically accomplished by adding simulated variable of a similar form

pymc3 : Multiple observed values

馋奶兔 提交于 2019-11-28 21:40:02
问题 I have some observational data for which I would like to estimate parameters, and I thought it would be a good opportunity to try out PYMC3. My data is structured as a series of records. Each record contains a pair of observations that relate to a fixed one hour period. One observation is the total number of events that occur during the given hour. The other observation is the number of successes within that time period. So, for example, a data point might specify that in a given 1 hour

Incremental model update with PyMC3

你说的曾经没有我的故事 提交于 2019-11-27 21:39:36
Is it possible to incrementally update a model in pyMC3. I can currently find no information on this. All documentation is always working with a priori known data. But in my understanding, a Bayesian model also means being able to update a belief. Is this possible in pyMC3? Where can I find info in this? Thank you :) Following @ChrisFonnesbeck's advice, I wrote a small tutorial notebook about incremental prior updating. It can be found here: https://github.com/pymc-devs/pymc3/blob/master/docs/source/notebooks/updating_priors.ipynb Basically, you need to wrap your posterior samples in a custom

how to fit a method belonging to an instance with pymc3?

。_饼干妹妹 提交于 2019-11-27 05:28:09
I failed to fit a method belonging to an instance of a class, as a Deterministic function, with PyMc3. Can you show me how to do that ? For simplicity, my case is summarised below with a simple example. In reality, my constraint is that everything is made through a GUI and actions like ‘find_MAP’ should be inside methods linked to pyqt buttons. I want to fit the function ‘FunctionIWantToFit’ over the data points. Problem, the following code: import numpy as np import pymc3 as pm3 from scipy.interpolate import interp1d import theano.tensor as tt import theano.compile class cprofile: def __init_

Incremental model update with PyMC3

[亡魂溺海] 提交于 2019-11-26 20:45:05
问题 Is it possible to incrementally update a model in pyMC3. I can currently find no information on this. All documentation is always working with a priori known data. But in my understanding, a Bayesian model also means being able to update a belief. Is this possible in pyMC3? Where can I find info in this? Thank you :) 回答1: Following @ChrisFonnesbeck's advice, I wrote a small tutorial notebook about incremental prior updating. It can be found here: https://github.com/pymc-devs/pymc3/blob/master