









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!










Having introduced the basics of BNs, in this lecture we will investigate the kinds of independence structure that is implied by a BN and introduce the con- cept of d-separation. We will then present methods of exact inference, including variable elimination and the sum-product algorithm for polytrees.
In order to gain a deeper understanding of the commitments made by the BN representation to different kinds of independence properties, we will first look at some basic examples of reasoning in BNs. The concepts are developed in the context of the example from last lecture.
Example 1. Causal reasoning is the pattern of reasoning that reasons from a cause to its effects (generally, from a variable to a descendant of a variable). Informally, we reason that a hard working student is more likely to understand the material, which in turn makes her more likely to do well on the homeworks. From this, we have ¬I(HG, HW), and failure of independence. On the other hand, if we now observe UM then we recover I(HG, HW | UM) and have condi- tional independence, given UM.
To understand this example, we introduce the concept of an information path being blocked by observations (or lack of observations.) In this case, UM blocks the information path between HG and HW. Once we observe UM then they become independent. We will see that the particular rule that explains why UM blocks the path in this case is because there is a single (undirected) path between HG and HW, and UM is a node on this path, where in considering the edges on the path, one of these points in and one edge points out of UM. For a direct proof of conditional indpendence given UM, we have
P (HG, HW | UM) =
Eq. (2) follows from the semantics of the Bayes Net, noting that
P (HG, HW, UM) =
x∈S,y∈GTT,z∈EG
P (HW)P (UM | HW, S = x)P (HG | UM)P (EG=z | GTT = y, UM)P (GTT, S = x)P (S = x) (5) =
x∈S,y∈GTT
P (HW)P (UM | HW, S = x)P (HG | UM)P (GTT, S = x)P (S = x)
∑
z∈EG
P (EG=z | GTT = y, UM) (6)
x∈S
P (HW)P (UM | HW, S = x)P (HG | UM)P (S = x)
y∈GTT
P (GTT, S = x)
x∈S
P (UM | HW, S = x)P (S = x) (8)
x∈S
P (UM | HW, S = x)P (S = x | HW) (9)
x∈S
P (S = x, UM | HW) (10)
Eq. (3) follows by noting that
P (HW | UM) =
by Bayes’ rule.
Example 2. Evidential reasoning is the reasoning from effects to its pos- sible causes (generally, from a variable to its ancestors). Informally, since a student who understands the material is more likely to do well on the homework than one who does not, observing that the student did well on the homework provides evidence that the student understood the material, which in turn pro- vides evidence that the student is a hard worker. We again see ¬I(HG, HW) and failure of independence. We do again have conditional independence, with I(HG, HW | UM). This follows in the same way as for causal reasoning.
Example 3. Mixed reasoning combines both causal and evidential reasoning. Informally, we reason that if we observe that a student did well on the exam, that provides evidence that she understood the material, which in turn makes it more likely that she did well on the homework. We have ¬I(HG, EG) and failure of independence. However HG and EG are conditionally independent given UM, and we have I(HG, EG | UM). If we know that the student understands the material, then observing a good example performance gives no extra information about how well she did on the homework.
that she understood the material. In this case, we cannot determine whether P (UM = true) goes up or down based on purely qualitative considerations. Still, we can reason about failure of conditional independence between a pair of random variables, where this fails if it fails due to just one of the reasoning types.
We can now formalize that it means for an information path in a BN to be blocked and use this to define a notion of d-separation and then a full charac- terization of conditional indpendence between nodes. The criterion captures all of the reasoning patterns described above: in particular, it should capture chaining of causal and evidential reasoning, effects with common cause, and causes of the same effect. It should capture cases where nodes become independent when more information is known, and cases of induced dependence. An undirected path from A to B is a path in the BN ignoring the edges. Con- sider an intermediate node W on such a path. We say that we have converging arrows at W if both edges on the path go into W.
Definition 1 (blocked). A path from A to B is blocked given C if there is a node W on the path where either (a) the path does not have converging arrows at W and W ∈ C, or (b) the path does have converging arrows at W and neither W nor its de- scendants are in C.
Intuitively, a path is “blocked” when information cannot flow from variable A to B along the path. The first condition (a) captures causal and eviden- tial reasoning patterns and also reasoning between effects with common cause. The second condition captures the problem observed with inter-causal reasoning above. Why the clause “nor any of its descendants”? Because observing some descendant Z of W provides us with evidence about W. This observation has the same effect as observing W directly, enabling a reasoning chain.
Definition 2 (d-separation). Node A is d-separated from B given observed variables C ⊆ X \ {A, B} if every undirected path from A to B is blocked given C.
Now we obtain a general theorm about how to read off conditional indpen- dence properties from BNs.
Theorem 1 (general conditional independence). Variable A is conditionally independent of B given variables C ⊆ X \ {A, B} if and only if A is d-separated from B given C.
Referring to our running example BN, it is a good exercise to check whether the following conditional independence properties hold:
A Bayesian network (BN) represents a probability distribution over features, representing the agent’s knowledge about the state of the world. Given the ob- servation of the values of some variables, then a natural task is one of inference: reasoning about the distribution on one or more other unobserved variables. Formally, we assume we are given a BN, with a set of variables X = X 1 ,... , Xm. To keep things simple, we shall assume for now that the agent is interested in reasoning about the probability of a single query variable Q, which we will sometimes choose to assume is X 1. The evidence variables are the variables X 2 ,... , Xℓ, and it will be convenient to denote them E 2 ,... , Eℓ. For each evidence variable Ej we observe its value, denoted ej. The remaining variables X \ {Q, E 2 ,... , Eℓ} are unobserved. The goal is to compute P (Q = q 1 | E 2 = e 2 ,... , Eℓ = eℓ), for all possible values q 1. In other words, we want to compute the conditional probability distribution over the query given the evidence. Short-hand: We abbreviate the above query as P (q 1 | e 2 ,... , eℓ), with P (Q 1 | e 2 ,... , eℓ) to denote the set of probabilities for all values that Q 1 can adopt. First, by the definition of conditional probability,
P (Q 1 | e 2 ,... , eℓ) =
P (Q 1 , e 2 ,... , eℓ) P (e 2 ,... , eℓ)
The denominator can be computed as:
P (e 2 ,... , eℓ) =
q 1
P (Q 1 = q 1 , e 2 ,... , eℓ). (17)
Moreover, the restriction to just a single query variable Q 1 is without loss of generality, because for two random variables we have
P (Q 1 , Q 2 | E) = P (Q 1 | Q 2 , E)P (Q 2 | E) (18)
and this can be computed as above. A similar chain rule expansion can be used for a set of three or more query variables.
xj to the right of all product terms not men- tioning xj.
xj f^1... fk, where each of the factors fj mentions Xj. This is evaluated for all possible values of the other variables mentioned by factors f 1 ,... , fk. The result is a function gj on this variables and not including Xj.
xj f^1... fk^ with^ gj^. The expression again has a sum-of-products form, but with the
xj eliminated. The main computational work happens in Step (4). The key point is that instead of summing over all possible values of all variables, we only need to sum over all possible values of the variables mentioned by the f 1 ,... , fk terms. This is often a much smaller number of variables, so the operation is much cheaper. The step of eliminating a single variable is repeated until there are no sum- mation variables {Xℓ+1,... , Xm} left to eliminate. At that point, the expression is a product of one or more terms, with no surrounding summation operations. We simply multiply together the product terms to get the answer.
Consider the following query on our example network: what is the probability that someone understands the material given that they received an A on the exam, but a C on the homework. Qualitatively, we have two conflicting pieces of evidence. The good exam grade provides evidence (in two ways!) that the student understood the mate- rial, while the poor homework grade provides conflicting evidence. We want to compute P (UM | EG = A, HG = C). As discussed earlier, it is sufficient to compute P (UM, EG = A, HG = C), and treat P (EG = A, HG = C) as a normalizing factor. We begin as follows:
P (UM, EG = A, HG = C) =
x∈HW
y∈GTT
z∈S
P (S = z)P (HW = x)
P (GTT = y | S = z)P (UM | S = z, HW = x)P (EG = A | GTT = y, UM)P (HG = C | UM)
Each of the product terms can be derived from the conditional probability tables that are part of the BN definition, and are listed in the previous lecture notes. For example, P (S = z) is simply a function of the value z of S, and is the conditional probability table for S. Meanwhile, P (HG = C | UM) is a function of the value of UM (but not of HG, which is a constant). It can be derived from the conditional probability table for HG. These tables are the basic elements from which we will compute the answer to the query. We proceed to eliminate the variables GTT, S and HW in turn. We begin
with GTT: ∑ x
y
z P^ (S^ =^ z)P^ (HW^ =^ x) P (GTT = y | S = z)P (UM | S = z, HW = x) P (EG = A | GTT = y, UM)P (HG = C | UM) =
x
z
y P^ (S^ =^ z)P^ (HW^ =^ x) P (GTT = y | S = z)P (UM | S = z, HW = x) P (EG = A | GTT = y, UM)P (HG = C | UM) =
x
z
y P^ (S^ =^ z)P^ (HW^ =^ x) P (UM | S = z, HW = x)P (HG = C | UM) P (GTT = y | S = z)P (EG = A | GTT = y, UM) =
x
z P^ (S^ =^ z)P^ (HW^ =^ x) P (UM | S = z, HW = x)P (HG = C | UM) (
x
z P^ (S^ =^ z)P^ (HW^ =^ x) P (UM | S = z, HW = x)P (HG = C | UM)gy (z, UM)
where
gy(z, UM) =
y∈Dom[GTT]
P (GTT = y | S = z)P (EG = A | GTT = y, UM)
is a function of the value z of S and of the query UM. It is computed as follows. Let f 1 (GTT, S) = P (GTT|S) and f 2 (GTT, UM) = P (EG = A|GTT, UM). f 1 and f 2 are represented by the following tables.
GTT S f 1 (GTT, S) false false 0. false true 0. true false 0. true true 0.
GTT UM f 2 (GTT, UM) false false 0. false true 0. true false 0. true true 0. First, for each set of values for GTT, S and UM, we compute the product of f 1 and f 2. h(GTT = y, S = z, UM = w) = f 1 (y, z)f 2 (y, w) We obtain the following intermediate table for h:
determines both the space required to represent the function and the amount of computation required to compute it. Both space and time are exponential in the number of variables mentioned by the function. Therefore, the goal in variable elimination is to obtain intermediate g func- tions that mention relatively few variables. In the above process, you can see that the number of variables mentioned by each of gy and gz is just 2. The size of the intermediate g functions is highly dependent on the order in which vari- ables are eliminated. As an exercise, see what happens if you eliminate S first in the above example. In this case, the elimination order S,HW,GTT generates an intermediate g term with 3 variables rather than 2. In general, the task of determining a good elimination order is itself a difficult one, at least for general BNs. For example, for general BNs it is NP-hard to determine whether there exists an elimination order such that no intermediate function mentions more than k variables. In practice, most implementations of inference for BNs use greedy heuristics to choose the elimination order. These seem to work fairly well. For example, a standard heuristic is to select as the next variable to eliminate the one that will generate a g function (intermediate factor) with as few variables as possible. Variable elimination is tractable for polytrees (where there are no undirected cycles), simply by eliminating variables from the leaves and working towards the query node. The amount of work required is linear in the representation of the CPTs. But, the problem that occurs is with general BNs, where exact probabilistic inference is #P-hard 1 (at least as hard as NP-hard problems.) For a given BN, the difficulty of inference depends on the number of variables in the interim product terms of variable elimination (or equivalently, on the number of remaining variables in a product term once a variable has been eliminated.) Moreover there are some BNs with a constant number of parents for each node in which every order provides an exponential blow-up in the number of variables that need to be considered in a product term! The elimination operation needs to be performed once for each of the vari- ables being eliminated, which is on the order of m, the number of variables in the network. The total time cost of variable elimination is
O(mK(|g|max+1)), (22)
where K is the maximum number of discrete values that can be adopted by each variable, and gmax is the number of variables of the largest intermediate function produced during the elimination process. It is possible to use a moral graph to reason about the number of variables in the largest intermediate function generated. Given a Bayesian network struc- ture G, a set of evidence variables E, and an elimination ordering Xℓ+1, ..., Xm, an induced graph W is constructed as follows:
(^1) These are problems that ask how many solutions there are, for example how may different variable assignments will satisfy a disjunctive Normal form formula in Boolean logic. Solving a #P-hard problem in polynomial time would imply P=NP.
(a) Eliminate Xj : For any i, k such that Xi and Xk have not yet been eliminated, and where Xi and Xk are both connected to Xj in W , add an edge from Xi to Xk in if there is not one already.
(a) (b) (c)
Figure 1: (a) Moral graph for our example BN; (b) with evidence variables removed; (c) induced graph for elimination order S,HW,GTT.
For example, consider our example Bayesian network, with the query P (UM | EG = A, HG = C), and the elimination order S, HW, GTT. Figure 1(a) shows the moral graph for the network. Notice that there is an edge between S and HW because both are parents of UM. Figure 1(b) shows the graph after we have removed evidence variables. Figure 1(c) shows the induced graph for this elimination order. When S is eliminated, we add an edge between its neighbors HW and GTT. After that, eliminating HW and GTT does not add any new edges. Consider, by contrast, the elimination order GTT, S, HW. When we eliminate GTT, its only neighbors are S and HW, and there is already an edge between them. When we next eliminate S, GTT has already been eliminated, so we do not add an edge between it and HW. In fact, the induced graph for this elimination order has no edges added, and is the one shown in Figure 1(b). What is the relationship between the induced graph and the number of variables mentioned by an intermediate factor? A clique of a graph is a maximal set of nodes that are all connected to each other; maximal means that the set of nodes is not a proper subset of another set of nodes that are all connected to each other.
We have focused so far on directed graphical models. But there is another very popular graphical probabilistic models, namely Markov Random Fields. In these models, the graph is undirected and the joint probability distribution is again a product of factors, just of a slightly different form. We have
P (x) =
C∈C
φC (xC ) (23)
C∈C
exp {−EC (xC )} (24)
where C ∈ C is a maximal clique in the set of maximal cliques defined by the graph and (^1) Z is just for normalization. The functions φC (xC ) are potential functions (required to be positive) and depends on the values of variables asso- ciated with nodes in clique C. Because these need to be non-negative, then we introduce an energy function EC (xC ) and adopt exp(−EC (xC )) on this func- tion, which can be positive or negative. A lower energy corresponds to a higher probability. Markov Random Fields (MRFs) do not have the causal structure of BNs, being undirected, but find application to problems with other kind of structure (e.g., spatial) such as found in vision and image analysis problems. The potential function can be considered to represent configurations of local variables that are preferred over others. The independence semantics of a MRF are simpler than those for a BN and we have I(A, B | C) if there are no paths from A to B when nodes C ⊆ X \ {A ∪ B} are removed. This gives the analogous notion of “separation” for MRFs. The same basic algorithms can be used for inference in MRFs as well as BNs. The general approach uses what are called factor graphs to describe the two different networks in a common form and allow for a simple, unified approach.
(Not required reading)
Theorem 1. The maximum number of non-evidence variables mentioned by a factor during the variable elimination process is the size of the largest clique in the induced graph.
Proof. To prove the theorem, we will show that two non-evidence variables are connected in the induced graph if and only if they both appear in the same factor at some point in the variable elimination process.
To prove the first direction, that the fact that two non-evidence variables are connected implies that they appear in the same factor, we will proceed by induction. The base case is the moral graph. There are two ways two variables may be connected in the moral graph. One is for one to be a parent of the other, in which case that both appear in the child’s CPT, and the other is for both to be parents of a common child, in which case they both appear in the common child’s CPT. In either case they both appear in the same factor. For the induction step, suppose an edge between Xi and Xk is added while variable Xj is eliminated. By construction, both Xi and Xk must have been connected to Xj. By the induction hypothesis, Xi and Xk must both have appeared in some common factor with Xj (though not necessarily the same one). In the variable elimination algorithm, these common factors will be multiplied together to produce the intermediate factor for eliminating Xj , so Xi and Xk appear together in the same factor. We conclude that if an edge between Xi and Xk is added at any point, Xi and Xk must appear in the same factor. To prove the second direction, that two non-evidence variables that appear in the same factor must be connected in the induced graph, we also proceed by induction. The base case is the set of factors corresponding to the CPTs of the BN. Each factor consists of a variable and its parents. Therefore the only ways in which two variables can appear in the same factor are for one to be a parent of the other or both to be parents of a common child. In both cases the variables are connected in the moral graph. Since no edges between non- evidence variables are deleted when going from the moral graph to the induced graph, there is an edge between them in the induced graph. For the induction step, consider the intermediate factor produced at some point in the variable elimination process. Suppose the variable being eliminated is Xj , and the non- evidence variables Xi and Xk both appear in the factor. By the definition of the variable elimination process, both Xi and Xk must have appeared in the same factor as Xj before Xj was eliminated. By the induction hypothesis, they must both have been connected to Xj. By construction of the induced graph, they must then become connected to each other after Xj is eliminated, if they were not connected already. Since no edges between non-evidence variables are removed during construction of the induced graph, we conclude that the variables are connected in the final induced graph. From these two statements, we can derive that the number of variables mentioned by the largest factor is the size of the largest clique in the induced graph. Consider any clique in the induced graph. If no variables in the clique are eliminated, then all variables must be query variables, and all are mentioned in the factor representing the final result. Otherwise, let Xj be the first variable to be eliminated in the clique. By the first direction above, all variables in the clique must have appeared in a factor together with Xj. Therefore all must appear in the intermediate factor for eliminating Xj. This shows that the number of variables mentioned by the largest factor must at least be the size of the maximal clique in the induced graph. Now consider the largest factor. By the second direction above, all variables in the factor must be connected together, therefore they must form a subset of a clique. Therefore the number