在 causalnex 中构建基于专业知识的贝叶斯网络

constructing an expertise based bayesian network in causalnex

到目前为止,在causalnex包中,我只遇到了从 数据。我想知道如何使用我的节点参数和来自专业知识的 CPD 创建我自己的网络。有人对此有一些参考或示例吗?

看起来 causalnex 不直接支持手动设置 CPD,但您可以查看底层代码,发现它使用的是 pgmpy BayesianModel 同时表示 causalnex BayesianNetwork 中的结构和 CPD。

有了它,您可以通过 add_cpds 添加您知道的 CPD,而不是拟合它们。要获取 BayesianModel 对象,它将是:bn._model,其中 bn 是您的 causalnex.BayesianNetwork 对象。

我不确定这是否会让您只想使用 pgmpy 而不是 causalnex!! causalnex 的最大好处似乎是它使用了 NOTEARS 算法,它可以帮助您为有向图构建加权邻接矩阵。话又说回来,它还为你协调了一些策划。

此外,来自 docs 的重要说明提醒您它不是 真正 连续的,而是 discretised/binned:

Bayesian Networks in CausalNex support only discrete distributions. Any continuous features, or features with a large number of categories, should be discretised prior to fitting the Bayesian Network. Models containing variables with many possible values will typically be badly fit, and exhibit poor performance.