我正在尝试使用伯努利分布在石榴中创建贝叶斯模型,但我不知道如何构建分布并创建条件表。我已经看到了石榴的 Monty Hall 示例,并试图效仿它。以下是我对此事的看法:
from pomegranate import BernoulliDistribution
from pomegranate import ConditionalProbabilityTable
from pomegranate import Node
from pomegranate import BayesianNetwork
model = BayesianNetwork
c1 = BernoulliDistribution(0.2)
c2 = BernoulliDistribution(0.2 * 4)
pCPT = cpt([
[True, True, 0.25],
[True, False, 0.75],
[False, True, 0.0],
[False, False, 1]
], parents=[c1, c2])
s1 = Node(c1, name="c1")
s2 = Node(c2, name="c2")
s3 = Node(pCPT, name="CPT")
model.add_nodes(s1, s2, s3)
model.add_edge(s1, s3)
model.add_edge(s2, s3)
model.bake()
这给了我以下错误:
AttributeError: 'pomegranate.distributions.BernoulliDistribution.Be' object has no attribute 'keys'