Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Plotting a Model created with PyMC3 as a graph

I am using the following code to create a simple Model with PyMC3:

import pymc3 as pm
import theano.tensor as tt

with pm.Model() as model:
    p = pm.Uniform("freq_cheating", 0, 1)
    p_skewed = pm.Deterministic("p_skewed", 0.5*p + 0.25)

    yes_responses = pm.Binomial("number_cheaters", 100, p_skewed, observed= 50) 

    step = pm.Metropolis()
    trace = pm.sample(25000, step=step)
    burned_trace50 = trace[2500:]

Is it possible to plot this model as a DAG?

like image 203
user8270077 Avatar asked Nov 03 '18 08:11

user8270077


1 Answers

Added in version 3.5 is the model_to_graphviz method, which does exactly that. For your example above, you'd use

pm.model_to_graphviz(model)

enter image description here

like image 97
merv Avatar answered Nov 14 '22 01:11

merv