wikillm

Concept · 1 paper · updated 2026-11-12

Bayesian scoring metric

Score a Bayesian network structure from data plus prior beliefs, so candidate graphs can be ranked. One paper gives a general metric (Be) and two closed forms: BDe for discrete variables with Dirichlet priors and BGe for Gaussian variables with normal-Wishart priors. Needs complete data and assessed priors. No experiments, so no accuracy numbers.

structure-learningbayesian-networksdirichlet-priornormal-wishart-prior

Markdown5 min read

AI-compiled overview, updated 2026-11-12, not yet reviewed by a human. Every claim cites its source; check it when a detail matters.

Overview

A Bayesian scoring metric assigns a number to each candidate structure of a Bayesian network, given a data set and prior beliefs. A higher score means the structure explains the data better, weighted by the prior. Structures are then ranked by this number. The score of a structure S is its relative posterior, p(D, H_S | ξ), up to a normalising constant. Dividing by a reference structure such as the empty graph gives the same ranking 1302.4957 §2 eq. 8.

The shared invariant is likelihood equivalence: two structures that imply the same independence statements receive the same score 1302.4957 §3 1302.4957 §7.3 Theorem 14. The priors are not chosen per structure. A single complete reference structure fixes all of them, through a small set of assumptions 1302.4957 §3 Theorem 2.

Only one card on this wiki covers the metric: Learning Bayesian Networks: A Unification for Discrete and Gaussian Domains. The paper reports no experiments, so every statement on this page is about the formulas, not about measured structure recovery.

Variants

General Be metric

The base metric for complete data. It requires four prior assumptions: likelihood equivalence, a positive prior on every complete structure, global parameter independence, and parameter modularity 1302.4957 §3. Under these, the score of any structure factorises into one term per child, each a ratio of marginal likelihoods on a complete reference structure 1302.4957 §4 Theorem 6 eq. 14. Card: Learning Bayesian Networks: A Unification for Discrete and Gaussian Domains.

BDe, discrete variables

The closed form for discrete variables. The joint parameters get a Dirichlet prior whose exponents come from an effective sample size N' and a prior network 1302.4957 §5.1 eq. 15. The score is a product of Gamma functions over each child and each parent configuration [arxiv:1302.4957 §5.1 Theorem 7] eq. 18. Card: Learning Bayesian Networks: A Unification for Discrete and Gaussian Domains.

BGe, Gaussian variables

The closed form for continuous variables. The prior is normal-Wishart with effective sizes N'_mu > 0 and N'_tau > n - 1, where n is the number of variables 1302.4957 §5.2 §6. The score uses the marginal over each child and its parents, with a multivariate gamma factor and a posterior scale matrix 1302.4957 §5.2 Theorem 8 eq. 21 eq. 23 eq. 24. Card: Learning Bayesian Networks: A Unification for Discrete and Gaussian Domains.

Mixed discrete and continuous domains

Order the discrete variables before the continuous ones. Use the BDe term for the discrete part, and a BGe term per discrete state for the continuous part 1302.4957 §5.2. The paper states this as a construction and gives no experiment on mixed data 1302.4957 §5.2 §6. Card: Learning Bayesian Networks: A Unification for Discrete and Gaussian Domains.

When to use which

SituationUseWhy
All variables discrete, complete data, and a prior network over the joint table can be assessedBDeClosed form with Gamma functions and one effective sample size N' 1302.4957 §5.1 eq. 18
All variables continuous, complete data, and effective sizes N'_mu and N'_tau can be setBGeClosed form for normal-Wishart priors 1302.4957 §5.2 eq. 23
Both kinds of variable in one networkMixed constructionDiscrete ordered first, BDe plus BGe per discrete state 1302.4957 §5.2
A prior family other than Dirichlet or normal-WishartGeneral Be metric, if the four assumptions hold for that priorThe paper's Theorem 6 is stated for any prior satisfying them 1302.4957 §4 §3
Missing values in the dataNone of the closed forms appliesClosed forms assume complete data 1302.4957 §4 Assumption 6; the paper names filling in, EM and Gibbs sampling but does not develop them 1302.4957 §4
Causal rather than acausal networkCheck likelihood equivalence as an assumptionFor causal networks the paper treats likelihood equivalence as a reasonable assumption in many domains, not a given 1302.4957 §3
Acausal network with many equivalent structuresScore equivalence classesThe paper says to score classes rather than single structures in the acausal case 1302.4957 §3

The paper gives no default values for the prior constants and no guidance on choosing the effective sample sizes. Prior assessment is described only in outline, and detailed methods are deferred to the 1994 Gaussian paper, which has no card here: arXiv:1302.6808 1302.4957 §6.

Implementation sketch

The core is the same for both closed forms: a score per child, computed from counts (discrete) or from marginal terms (Gaussian), plus the log structure prior. The BDe version below works in logs. Its only inputs are counts and a prior count table.

Pseudocode
# BDe log score of one structure  [§5.1] [eq. 18] [eq. 19]
# counts[i][j, k] = N_ijk; prior[i][j, k] = N'_ijk  [eq. 19]
# Output: log p(D, H_S | xi), with log p(H_S | xi) added in
def bde_log_score(counts, prior, log_structure_prior):
    total = log_structure_prior              # log p(H_S | xi)  [§2]
    for child in range(len(counts)):
        # N'_ij and N_ij: sums over the child states k  [eq. 19]
        prior_cfg = prior[child].sum(axis=1)
        count_cfg = counts[child].sum(axis=1)
        # Gamma(N'_ij) / Gamma(N'_ij + N_ij), product over j  [eq. 18]
        total += gammaln(prior_cfg).sum()
        total -= gammaln(prior_cfg + count_cfg).sum()
        # Gamma(N'_ijk + N_ijk) / Gamma(N'_ijk), product over j and k
        total += gammaln(prior[child] + counts[child]).sum()
        total -= gammaln(prior[child]).sum()
    return total

For the Gaussian case, the same loop applies with each child term replaced by the difference of two marginal terms, one with the child in the subset and one without 1302.4957 §4 Theorem 6 eq. 14. Each marginal term uses the Wishart degrees of freedom nu = N'_tau - n + l, where l is the subset size 1302.4957 §5.2 eq. 23.

Pitfalls

  • Corrected exponent. The source marks a correction in red, taken from a 2014 addendum. The corrected marginal degrees of freedom are N'_tau - n + l 1302.4957 §5.2 eq. 23. Code written from older text may use another exponent, which the paper does not state as an error; use the corrected form.
  • Scatter matrix undefined. The posterior scale matrix uses a sample scatter matrix S_m whose formula the paper does not write out. It defers that formula to the 1994 Gaussian paper 1302.4957 §5.2.
  • Empty parent sets. The child-over-parents ratio needs a term for an empty parent set, which the paper does not define. Root nodes need that term to be 1 1302.4957 §4 eq. 14. Check the implementation against this.
  • Zero prior cells. The BDe closed form takes Gamma(0) when a prior cell is zero. The paper's positive-prior assumption on complete structures means each cell should stay positive 1302.4957 §3 eq. 18.
  • Choice of reference. The score does not depend on the reference complete structure by Theorem 14 1302.4957 §7.3, but the prior that is assumed does depend on it 1302.4957 §4 §5.
  • Numerics. Products of Gamma functions and determinants overflow for many variables. Work in logs. The paper gives no numerical guidance.
  • No validation. The paper measures nothing about structure recovery, predictive accuracy or runtime. Test any implementation on a known network before use 1302.4957 §5.

Contradictions

None known. Only one card covers this slug.

Papers

Source and license

Compiled from the papers listed on this page, all published under CC BY, CC BY-SA or CC0, with citations. See each paper's page for its authors and license.