将使用PyMC3创建的模型绘制为图形

问题描述 投票:2回答:1

我使用以下代码创建一个使用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:]

是否可以将此模型绘制为DAG?

您的建议将不胜感激

python-3.x directed-acyclic-graphs pymc3
1个回答
1
投票

Added in version 3.5model_to_graphviz方法,它就是这样做的。对于上面的例子,你可以使用

pm.model_to_graphviz(model)

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.