Plotting a Model created with PyMC3 as a graph
Asked Answered
P

1

9

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?

Paracasein answered 3/11, 2018 at 8:9 Comment(0)
C
12

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

Cornerwise answered 4/11, 2018 at 18:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.