gpt4 book ai didi

python - Python 中的贝叶斯网络 : both construction and sampling

转载 作者:行者123 更新时间:2023-11-30 21:54:25 25 4
gpt4 key购买 nike

对于一个项目,我需要创建包含属性之间特定依赖关系的综合分类数据。这可以通过从预定义的贝叶斯网络中采样来完成。经过在互联网上的一些探索,我发现 Pomegranate 是贝叶斯网络的一个很好的软件包,但是 - 就我而言 - 似乎不可能从这样一个预定义的贝叶斯网络中进行采样。例如,model.sample() 引发 NotImplementedError(尽管 this 解决方案是这么说的)。

有谁知道是否存在一个库可以为贝叶斯网络的构建和采样提供良好的接口(interface)?

最佳答案

使用 pyAgrum,您只需:

#import pyAgrum
import pyAgrum as gum

# create a BN
bn=gum.fastBN("A->B[3]<-C{yes|No}->D")
# specify some CPTs (randomly filled by fastBN)
bn.cpt("A").fillWith([0.3,0.7])

# and then generate a database
gum.generateCSV(bn,"sample.csv",1000,with_labels=True,random_order=False)
# which returns the LL(database)

the code in a notebook

参见http://webia.lip6.fr/~phw/aGrUM/docs/last/notebooks/更多使用 pyAgrum 的笔记本

免责声明:我是 pyAgrum 的作者之一:-)

关于python - Python 中的贝叶斯网络 : both construction and sampling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59107319/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com