Questions tagged [pymc3]

PyMC (formerly PyMC3) is a Python module that implements Bayesian statistical models and fitting algorithms, including Markov chain Monte Carlo. Its flexibility and extensibility make it applicable to a large suite of problems. Along with core sampling functionality, PyMC includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics.

PyMC is a Python module that implements Bayesian statistical models and fitting algorithms, including Markov chain Monte Carlo.

Its flexibility and extensibility make it applicable to a large suite of problems. Along with core sampling functionality, PyMC includes methods for summarizing output, plotting, goodness-of-fit and convergence diagnostics.

706 questions
4
votes
0 answers

pymc3: NUTS sampling, multiple hierarchical model, Wishart distribution

I have problems with NUTS sampling in hierarchical model in pymc3. I've done some simpler models in pymc3 without any problems, but with this assignment I can't move. Can someone help me please? Data can be obtained from here: cars2004.csv. First…
kostovcik
  • 41
  • 2
4
votes
2 answers

Percentage match in pandas Dataframe

Is there a function that tells the percentage or number of matches in a pandas DataFrame without doing something like this... len(trace_df[trace_df['ratio'] > 0]) / len(trace_df) 0.189 len(trace_df[trace_df['ratio'] <= 0]) /…
SARose
  • 3,558
  • 5
  • 39
  • 49
4
votes
2 answers

save PyMC3 traceplot subplots to image file

I am trying very simply to plot subplots generated by the PyMC3 traceplot function (see here) to a file. The function generates a numpy.ndarray (2d) of subplots. I need to move or copy these subplots into a matplotlib.figure in order to save the…
GoneAsync
  • 349
  • 5
  • 18
4
votes
1 answer

Pymc3 Conditional Posterior Sampling

I want to sample from the posterior distributions in pymc3 but conditional on specific values of certain variables. I see how to sample the posteriors with sample_ppc, but it is unclear how to do this conditionally. Is there a simple way? For…
Ryan
  • 53
  • 5
4
votes
1 answer

Predicting from inferred parameters in pymc3

I am trying to understand this from a non-Bayesian background. In linear regression or blackbox machine learning tools the work flow is something like the following. Get data Prepare data Model data (learn from it [or part of it, the training…
John Smith
  • 81
  • 2
4
votes
0 answers

PyMC3 DensityDist not working for simple example

I'm trying to combine the values of 2 vectors and learn the latent probability distribution for one of the vectors. However when I try and do this combination with DensityDist wit the 'obs' variable I'm not recovering the injected distribution. …
Chris
  • 676
  • 5
  • 20
4
votes
0 answers

Re-running a model with new data in pymc3

I was wondering if there is some mechanism in pymc3 to re-run a model with new data. After setting up the model and before sampling, I assume that pymc3 does some optimization (and compilation?) of the model which takes quite some time. I would like…
4
votes
1 answer

PyMC3 regression with change point

I saw the examples of how to do change point analysis with pymc3, but it seems that I'm missing something because the results I get are far from true values. Here's a toy example. Data: Script: from pymc3 import * from numpy.random import uniform,…
4
votes
1 answer

PyMC3 select data within model for switchpoint analysis

I am generating a time series that has a drastic change in the middle. import numpy as np size = 120 x1 = np.random.randn(size) x2 = np.random.randn(size) * 4 x = np.hstack([x1, x2]) This series of x looks like this: The goal is now to use…
cantdutchthis
  • 31,949
  • 17
  • 74
  • 114
4
votes
1 answer

Softmax Regression (Multinomial Logistic) with PyMC3

I am trying to implement a logistic multinomial regression (AKA softmax regression). In this example I am trying to classify the iris dataset I have a problem specifying the model, I get an optimization error with find_MAP(). If I avoid using…
aloctavodia
  • 2,040
  • 21
  • 28
4
votes
1 answer

Conditional Probability Using Pymc3

My question is how to use PYMC3 package to carry out conditional probability models. I have a set of data a_observed, b_observed, c_observed, and I want to find the relations between them. I suspect that a, b, c are all normal distributions, b…
Shidan Xu
  • 41
  • 2
4
votes
1 answer

What are the interval transforms in pymc3 for uniform distributions?

I've noticed that when using uniform distributions in pymc3, the sampler also scans over an _interval parameter as well unless a transform is specified for example: with fitModel6: normMu = pm.Uniform('normMu',lower=0,upper=1000) will result…
J. Michael
  • 41
  • 4
4
votes
1 answer

Linear regression with pymc3 and belief

I am trying to grasp Bayesain statistics with pymc3 I ran this code for a simple linear regression #Generating data y=a+bx import pymc3 import numpy as np N=1000 alpha,beta, sigma = 2.0, 0.5, 1.0 np.random.seed(47) X = np.linspace(0, 1, N) Y = alpha…
Uri Goren
  • 13,386
  • 6
  • 58
  • 110
4
votes
1 answer

Is PyMC3 useful for creating a latent dirichlet allocation model?

I've spent the last several weeks trying to learn PyMC whereby my main task is using it to build an LDA topic model. I originally tried this example with PyMC2.3 https://stats.stackexchange.com/questions/104771/latent-dirichlet-allocation-in-pymc…
Chris
  • 676
  • 5
  • 20
4
votes
3 answers

Porting PyMC2 code to PyMC3 - hierarchical model for sports analytics

I tried the following code, but I ran into problems. I think .values is the problem but how do I encode this as a Theano object? The following is my data…
Peadar Coyle
  • 2,203
  • 3
  • 16
  • 20