有没有办法在Python中使用BNLearn绘制贝叶斯网络及其边际分布?

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

我正在 Python 中使用 BNLearn 进行推理,并且想创建一个类似于所附图像的绘图。 可以吗?

我尝试使用PyAgrum,但发现它很难使用。我尝试使用 Graphviz,但没有成功。 enter image description here

bayesian-networks py-bnlearn
1个回答
0
投票

你能解释一下为什么你觉得 pyAgrum 很难吗?

代码:

import pyAgrum as gum
import pyAgrum.lib.notebook as gnb

bn=gum.fastBN("C{a|b|c}->D{a|b|c}<-A{a|b|c}->B{a|b|c}->E{a|b|c}<-F{a|b}")

bn.cpt("A").fillWith(1).normalize()
bn.cpt("C").fillWith([0.743,0.205,0.052])
bn.cpt("F").fillWith([0.502,0.498])

gnb.sideBySide(gnb.getBN(bn),gnb.getInference(bn),gnb.getInference(bn,evs={"B":"b"},targets={"B","C","F","E"}))
© www.soinside.com 2019 - 2024. All rights reserved.