贝叶斯网络结构学习数据集

时间:2019-12-25 02:11:15

标签: machine-learning dataset bayesian-networks

经过大量研究,我没有找到具有必要材料的存储库来测试能够学习贝叶斯网络结构的算法。我只需要两件事:

  • 正确的贝叶斯网络
  • 与国阵有关的数据集

我的算法应该能够从数据集中学习结构,然后可以检查距正确的BN有多远。你有链接吗?我已经找到了一些没有原始BN的数据集,反之亦然,但是在我的大学项目中我都需要它们。

预先感谢

PS:如果您有兴趣,我会在项目中使用Python。

1 个答案:

答案 0 :(得分:1)

尝试使用bnlearn库。该库包含结构学习,参数学习,推论和与BN相关的数据集,例如洒水器,亚洲,警报等。有关结构学习和推断,请参见下面的示例。

https://erdogant.github.io/bnlearn

# Load asia DAG
import bnlearn

DAG = bnlearn.import_DAG('asia')
# plot ground truth

G = bnlearn.plot(DAG)
# Sampling

df = bnlearn.sampling(DAG, n=10000)

# Structure learning of sampled dataset
model_sl = bnlearn.structure_learning.fit(df, methodtype='hc', scoretype='bic')

# Plot based on structure learning of sampled data
bnlearn.plot(model_sl, pos=G['pos'])

# Compare networks and make plot
bnlearn.compare_networks(model, model_sl, pos=G['pos'])

请注意,bnlearn库是建立在pgmpy上的。安装如下:

# Create new env.
conda create -n BNLEARN python=3.6
conda activate BNLEARN
conda install -c ankurankan pgmpy

# dectivate/activate
conda deactivate
conda activate BNLEARN

# install bnlearn
pip install bnlearn