Bayesian Network Variable Elimination
Inference in graphical models involves computing conditional probability answers to queries:
- Compute the posterior probability distributions, given values
for some evidence nodes - Belief updating or probabilistic inference
Types of inference:
- Exact inference: variable elimination
- Approximate inference
Naive inference algorithm for computing conditional probability
- Step 1: Get joint probability distribution
over the set of ALL variables by multiplying conditional probability (chain rule) - Step 2: Marginalization: to find
and then is the set of non-query, non-evidence variables. - Step 3: Renormalization: Calculate the conditional probability: based on the evidence
To perform inference effectively:
- Structure of the Bayesian network: DAG and CPDs
- Conditional independence assertion
- Factorization of the joint distribution
Conditional Probability Query
Posterior Probability Query
It means finding the probability of some variable(s) after knowing certain evidence.
- (a) Given the values of some variables (the evidence).
- (b) Compute the posterior probability of other variables — used for prediction, explanation, or reasoning.
- (c) Example:
If John and Mary both called the police because of an alarm, what’s the probability that there was actually an earthquake?
General form of query
(a) Notations:
is a list of query variables, sometimes we use letter as well. is a list (set) of evidence variables is the corresponding list observed values : random variables that are neither query nor evidence, are ALL the random variables of the joint distribution .
(b) Computing probabilities
i.
ii. The probability of evidence
(c) Deriving conditional probabilities
if
and renormalizing the entries to 1 by dividing the sum of them
(d) Inference: the process of computing the answer to a query.
Types of exact inferences
(a) Predictive/Causal inference:
Determining the likelihood of an effect given a cause. From causes to effects
If burglary
(b) Diagnostic (evidential/abductive)
It seeks to identify the causes given an observed effect. From effect to causes:
Mary calls
(c) Inter-causal inference (explaining away)
Inter-causal inference deals with the relationship between different causes of a common effect. It can demonstrate how one cause can reduce the probability of another cause given the effect.
Between causes of a common effect
Earthquake
(d) Mixed inference
simultaneous use of diagnostic and causal inference simultaneous use of diagnostic and inter-causal inference
Naive Inference
- Step 1: Get the joint distribution:
- Step 2: Marginalize: to compute the marginal probability of a given variable in our model after summing everything else out
e.g.,
- Step 3: Condition inference (Baye’s Theorem):
- The naive algorithm does not make use of the factorization, and has exponential complexity (bad!!).
- Eliminating a variable
from the joint distribution is to compute:
But the complexity is exponential in
We need better ways to eliminate variables with much less computation using factorization. How to use the factorization to reduce the complexity.
Variable Elimination Simple Chain Example
We have a simple Bayesian network:
and we want to compute
Compute
Naive Method
- 做法:先求出完整的联合分布
,再逐一消除变量。 - 复杂度计算:
- :消除 时,需要处理关于 的因子,大小为 。 - :消除 时,需要处理关于 的因子,大小为 。 - :消除 时,需要处理关于 的因子,大小为 。 - 缺点:复杂度随变量增加呈 指数级增长 (
)。
Variable Elimination
- 做法:利用因子分解,每次只对局部相关的变量求和。
- 复杂度计算:
- :计算 ,只涉及 2 个变量,生成关于 的因子。 - :计算 ,只涉及 2 个变量,生成关于 的因子。 - :计算 ,只涉及 2 个变量,生成关于 的因子。 - 优点:复杂度随变量增加呈 线性增长 (
)。
Theorem
Suppose
假设你有一个由很多小因子(函数)相乘构成的系统。当你对其中一个变量
Proof:
Suppose
the factors where
Factor Marginalization
Definition of factor marginalization: Let
We sum up entries in the table where the values of
Procedure of Variable Elimination :
- Input:
: a list of functions; : a variable to be eliminated. - Output: another list of factor functions
:
- Remove from the
all the functions, say , that involve . - Compute new function
, e.g., and . - Compute new function
, e.g., , which is a marginal probability distribution. - Add new function
to to replace . - Return
as .
Sum-product inference task: Compute:
Variable Elimination Algorithm
Inputs:
: the list of conditional probability tables in a BN; set of factors : a list of query variables; : a list of observed variables; : observed values; : eliminating order of variables which are not in
Output:
, the query answer While
is not empty - eliminate the first variable
from - call function
endwhile.
- eliminate the first variable
Set
to be the product of all the factors in Instantiate observed variables in
to their observed values Re-normalization:
Return
Example
Conditional Probability Inference
digraph G {
// Set global graph, node, and edge attributes
graph [rankdir=TB];
node [shape=circle, style=filled, color=lightblue, fontname="Helvetica", fontsize=12];
edge [color=black];
// Define nodes
A [label="A"];
B [label="B"];
C [label="C"];
D [label="D"];
E [label="E"];
F [label="F"];
// Define edges
A -> D;
B -> D;
B -> E;
C -> E;
D -> F;
E -> F;
}Query
This Bayesian network (BN) factorizes
So the initial factorization:
Elimination order for the non-query, non-evidence variables:
Inference process:
- Step 1: Eliminate all non-query variables:
Eliminate C (furthest): So we have the new marginal function:
Assuming all variables are binary, the cost of eliminating
is (index 3 is the number of variables involved in this process). Eliminate E: Only two factors contain
in , while three factors contain : The cost of eliminating
is . Eliminate B:
Eliminate D:
- Step 2: Deal with the evidence variable:
- Step 3: Instantiation for
: - This
is an un-normalized factor, because may not be 1.
- Step 4: Re-normalization and obtain the conditional probability:
Marginal Probability Inference
digraph BayesianNetwork {
// Node attributes
node [shape=ellipse, fontname="Helvetica", fontsize=12, style=solid];
// Nodes
Coherence;
Difficulty;
Intelligence;
Grade;
SAT;
Letter;
Job;
Happy;
// Edges
Coherence -> Difficulty;
Difficulty -> Grade;
Intelligence -> Grade;
Intelligence -> SAT;
Grade -> Letter;
SAT -> Job;
Letter -> Job;
Job -> Happy;
Difficulty -> Happy;
}(a) The chain rule for this Student BN asserts that
So, we have the list of function factors:
(b) Apply VE algorithm to compute
- p:
- q:
i. Eliminating : Compute the factors with sum-production operation
In this case,
ii. Eliminating :
Now the list of factors are:
iii. Eliminating :
There are three factors involving
Now the list of factors are:
iv. Eliminating :
There is only one factor involving
Note that:
We generated this new factor, but it does not complicate the algorithm. Now the list of factors are:
v. Eliminating :
There are three factors related to
So now the list of factors are:
vi. Eliminating :
So now the list of factors are:
vii. Eliminating :
Then we renormalize
- We can use any elimination ordering, but some are obviously better than the others.
- The optimal elimination ordering: the one with minimum cost.