Describing Data • The canonical descriptive strategy is to describe the data in terms of their underlying distribution • As usual, we have a p-dimensional data matrix with variables X 1 , …, X p • The joint distribution is P(X 1 , …, X p ) • The joint gives us complete information about the variables • Given the joint distribution, we can answer any question about the relationships among any subset of variables – are X2 and X5 independent? – generating approximate answers to queries for large databases or selectivity estimation • Given a query (conditions that observations must satisfy), estimate the fraction of rows that satisfy this condition (the selectivity of the query) • These estimates are needed during query optimization • If we have a good approximation for the joint distribution of data, we can use it to efficiently compute approximate selectivities
Describing Data. The canonical descriptive strategy is to describe the data in terms of their underlying distribution As usual, we have a p-dimensional data matrix with variables X 1 , …, X p The joint distribution is P(X 1 , …, X p ) The joint gives us complete information about the variables - PowerPoint PPT Presentation
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Describing Data
• The canonical descriptive strategy is to describe the data in terms of their underlying distribution
• As usual, we have a p-dimensional data matrix with variables X1, …, Xp
• The joint distribution is P(X1, …, Xp)• The joint gives us complete information about the
variables• Given the joint distribution, we can answer any question
about the relationships among any subset of variables– are X2 and X5 independent?– generating approximate answers to queries for large
databases or selectivity estimation• Given a query (conditions that observations must satisfy),
estimate the fraction of rows that satisfy this condition (the selectivity of the query)
• These estimates are needed during query optimization • If we have a good approximation for the joint distribution of data,
we can use it to efficiently compute approximate selectivities
Graphical Models
• In the next 3-4 lectures, we will be studying graphical models
• e.g. Bayesian networks, Bayes nets, Belief nets, Markov networks, etc.
• We will study:– representation– reasoning– learning
• Materials based on upcoming book by Nir Friedman and Daphne Koller. Slides courtesy of Nir Friedman.
Probability Distributions
• Let X1,…,Xp be random variables
• Let P be a joint distribution over X1,…,Xp
If the variables are binary, then we need O(2p) parameters to describe P
Can we do better?• Key idea: use properties of independence
Independent Random Variables
• Two variables X and Y are independent if– P(X = x|Y = y) = P(X = x) for all values x,y– That is, learning the values of Y does not change
prediction of X
• If X and Y are independent then – P(X,Y) = P(X|Y)P(Y) = P(X)P(Y)
• In general, if X1,…,Xp are independent, then– P(X1,…,Xp)= P(X1)...P(Xp)
– Requires O(n) parameters
Conditional Independence
• Unfortunately, most of random variables of interest are not independent of each other
• A more suitable notion is that of conditional independence
• Two variables X and Y are conditionally independent given Z if– P(X = x|Y = y,Z=z) = P(X = x|Z=z) for all values x,y,z– That is, learning the values of Y does not change prediction
of X once we know the value of Z
– notation: I ( X , Y | Z )
Example: Naïve Bayesian Model
• A common model in early diagnosis:– Symptoms are conditionally independent given the
disease (or fault)
• Thus, if – X1,…,Xp denote whether the symptoms exhibited by
the patient (headache, high-fever, etc.) and – H denotes the hypothesis about the patients health
• then, P(X1,…,Xp,H) = P(H)P(X1|H)…P(Xp|H),
• This naïve Bayesian model allows compact representation
– It does embody strong independence assumptions
Modeling assumptions:Ancestors can affect descendants' genotype only by passing genetic materials through intermediate generations
Example: Family trees
Noisy stochastic process:
Example: Pedigree• A node represents
an individual’sgenotype
Homer
Bart
Marge
Lisa Maggie
Markov Assumption
• We now make this independence assumption more precise for directed acyclic graphs (DAGs)
• Each random variable X, is independent of its non-descendents, given its parents Pa(X)
• Formally,I (X, NonDesc(X) | Pa(X))
Descendent
Ancestor
Parent
Non-descendent
X
Y1 Y2
Non-descendent
Markov Assumption Example
• In this example:– I ( E, B )– I ( B, {E, R} )– I ( R, {A, B, C} | E )– I ( A, R | B,E )– I ( C, {B, E, R} | A)
Earthquake
Radio
Burglary
Alarm
Call
I-Maps
• A DAG G is an I-Map of a distribution P if all the Markov assumptions implied by G are satisfied by P(Assuming G and P both use the same set of random
variables)
Examples:
X Y
x y P(x,y)0 0 0.250 1 0.251 0 0.251 1 0.25
X Y
x y P(x,y)0 0 0.20 1 0.31 0 0.41 1 0.1
Factorization
• Given that G is an I-Map of P, can we simplify the representation of P?
• Example:
• Since I(X,Y), we have that P(X|Y) = P(X)• Applying the chain rule
P(X,Y) = P(X|Y) P(Y) = P(X) P(Y)
• Thus, we have a simpler representation of P(X,Y)
X Y
Factorization Theorem
From assumption:
)X(NonDesc)X(Pa}X,X{
}X,X{)X(Pa
ii1i,1
1i,1i
⊆−
⊆
−
−
K
K
∏=i
iip1 ))X(Pa|X(P)X,...,X(P
Thm: if G is an I-Map of P, then
∏ −=i
1i1ip1 )X,...,X|X(P)X,...,X(PProof:• By chain rule:
• wlog. X1,…,Xp is an ordering consistent with G
• Since G is an I-Map, I (Xi, NonDesc(Xi)| Pa(Xi))
Pros:• Very flexible, can capture any CPD of discrete
variables• Can be easily stored and manipulated
Cons:• Representation size grows exponentially with
the number of parents!• Unwieldy to assess probabilities for more than
few parents
Structured CPD
• To avoid the exponential blowup in representation, we need to focus on specialized types of CPDs
• This comes at a cost in terms of expressive power
• We now consider several types of structured CPDs
Causal Independence
• Consider the following situation
• In tabular CPD, we need to assess the probability of fever in eight cases
• These involve all possible interactions between diseases
• For three disease, this might be feasible….For ten diseases, not likely….
Disease 1 Disease 3Disease 2
Fever
Causal Independence
• Simplifying assumption:– Each disease attempts to cause fever, independently of the
other diseases– The patient has fever if one of the diseases “succeeds”
• We can model this using a Bayesian network fragment
Fever
Fever 1 Fever 3Fever 2
Disease 1 Disease 3Disease 2
OR gate
F = or(SF,F1,F2,F3)Hypothetical variables
“Fever caused by Disease i”
SpontenuousFever
Noisy-Or CPD
• Models P(X|Y1,…,Yk), X, Y1,…, Yk are all binary
• Paremeters:– pi -- probability of X = 1 due to Yi = 1
– p0 -- probability of X = 1 due to other causes
• Plugging these in the model we get
),...,|0(1),...,|1(
)1()1(),...,|0(
11
01
kk
i
Yik
YYXPYYXP
ppYYXP i
=−==
−−== ∏
Noisy-Or CPD
• Benefits of noisy-or– “Reasonable” assumptions in many domains
• e.g., medical domain
– Few parameters. – Each parameter can be estimated independently of
the others
• The same idea can be extended to other functions:noisy-max, noisy-and, etc.
• Frequently used in large medical expert systems
Context Specific Independence
• Consider the following examples:
• Alarm sound depends on– Whether the alarm
was set before leaving the house– Burglary– Earthquake
• Arriving on time depends on – Travel route– The congestion on the two
possible routes
Set EarthquakeBurglary
Alarm
TravelRoute
Route 2traffic
Route 1traffic
Arrive ontime
Context-Specific Independence
• In both of these example we have context-specific indepdencies (CSI)– Independencies that depends on a particular value of
one or more variables
• In our examples:– Ind( A ; B, E | S = 0 )
Alarm sound is independent of B and E when the alarm is not set
– Ind( A ; R2 | T = 1 )Arrival time is independent of traffic on route 2 if we choose to travel on route 1
Representing CSI
• When we have such CSI, P(X | Y1,…,Yk ) is the same for several values of Y1,…,Yk
• There are many ways of representing these regularities
• A natural representation: decision trees– Internal nodes: tests on parents– Leaves: probability distributions on X
• Evaluate P(X | Y1,…,Yk ) by traversing tree
S
B
.0
E .8
.1 .7
0 1
0 1
0 1
Detecting CSI
• Given evidence on some nodes, we can identify the “relevant” parts of the trees– This consists of the paths in the tree that are consistent with
context
• Example – Context S = 0– Only one path of tree is relevant
• A parent is independent given the context if it does not appear on oneof the relevant paths
S
B
.0
E .8
.1 .7
0 1
0 1
0 1
Decision Tree CPDs
Benefits• Decision trees offer a flexible and intuitive
language to represent CSI • Incorporated into several commercial tools for
constructing Bayesian networks
Comparison to noisy-or• Noisy-or CPDs require full trees to represent• General decision tree CPDs cannot be
represented by noisy-or
Inference in Bayesian Inference in Bayesian NetworksNetworks
Inference
• We now have compact representations of probability distributions:– Bayesian Networks– Markov Networks
• Network describes a unique probability distribution P
• How do we answer queries about P?
• We use inference as a name for the process of computing answers to such queries
Queries: Likelihood
• There are many types of queries we might ask. • Most of these involve evidence
– An evidence e is an assignment of values to a set E variables in the domain
– Without loss of generality E = { Xk+1, …, Xn }
• Simplest query: compute probability of evidence
• This is often referred to as computing the likelihood of the evidence
∑ ∑=1x
1 ),,,( )(kx
kxxPP ee KK
Queries: A posteriori belief
• Often we are interested in the conditional probability of a variable given the evidence
• This is the a posteriori belief in X, given evidence e
• A related task is computing the term P(X, e) – i.e., the likelihood of e and X = x for values of X – we can recover the a posteriori belief by
∑′
′==
==
x
xXPxXP
xXP),(
),()|(
ee
e
)(),(
)|(eP
eXPeXP =
A posteriori belief
This query is useful in many cases:• Prediction: what is the probability of an outcome
given the starting condition– Target is a descendent of the evidence
• Diagnosis: what is the probability of disease/fault given symptoms– Target is an ancestor of the evidence
• As we shall see, the direction between variables does not restrict the directions of the queries– Probabilistic inference can combine evidence form all
parts of the network
Queries: A posteriori joint
• In this query, we are interested in the conditional probability of several variables, given the evidence
P(X, Y, … | e )
• Note that the size of the answer to query is exponential in the number of variables in the joint
Queries: MAP
• In this query we want to find the maximum a posteriori assignment for some variable of interest (say X1,…,Xl )
• That is, x1,…,xl maximize the probability
P(x1,…,xl | e)
• Note that this is equivalent to maximizing
P(x1,…,xl, e)
Queries: MAP
We can use MAP for:• Classification
– find most likely label, given the evidence
• Explanation – What is the most likely scenario, given the evidence
Queries: MAP
Cautionary note:• The MAP depends on the set of variables• Example:
– MAP of X– MAP of (X, Y)
x y P(x,y)
0 0 0.35
0 1 0.05
1 0 0.3
1 1 0.3
Complexity of Inference
Thm:Computing P(X = x) in a Bayesian network is NP-hard
Not surprising, since we can simulate Boolean gates.
Hardness
• Hardness does not mean we cannot solve inference– It implies that we cannot find a general procedure
that works efficiently for all networks– For particular families of networks, we can have
provably efficient procedures
Approaches to inference
•Exact inference – Inference in Simple Chains– Variable elimination– Clustering / join tree algorithms
•Approximate inference– Stochastic simulation / sampling methods– Markov chain Monte Carlo methods– Mean field theory
Inference in Simple Chains
How do we compute P(X2)?
X1 X2
∑∑ ==11
)|()(),()( 121212xx
xxPxPxxPxP
Inference in Simple Chains (cont.)
How do we compute P(X3)?
• we already know how to compute P(X2)...
X1 X2
∑∑ ==22
)|()(),()( 232323xx
xxPxPxxPxP
X3
∑∑ ==11
)|()(),()( 121212xx
xxPxPxxPxP
Inference in Simple Chains (cont.)
How do we compute P(Xn)?
• Compute P(X1), P(X2), P(X3), …
• We compute each term by using the previous one
∑ ++ =ix
iiii xxPxPxP )|()()( 11
X1 X2 X3Xn
...
Complexity:
• Each step costs O(|Val(Xi)|*|Val(Xi+1)|) operations
• Compare to naïve evaluation, that requires summing over joint values of n-1 variables
Inference in Simple Chains (cont.)
• Suppose that we observe the value of X2 =x2
• How do we compute P(X1|x2)?– Recall that we it suffices to compute P(X1,x2)
X1 X2
)()|(),( 11221 xPxxPxxP =
Inference in Simple Chains (cont.)
• Suppose that we observe the value of X3 =x3
• How do we compute P(X1,x3)?
• How do we compute P(x3|x1)?
X1 X2
)|()(),( 13131 xxPxPxxP =
X3
∑
∑∑=
==
2
22
)|()|(
),|()|()|,()|(
2312
2131213213
x
xx
xxPxxP
xxxPxxPxxxPxxP
Inference in Simple Chains (cont.)
• Suppose that we observe the value of Xn =xn
• How do we compute P(X1,xn)?
• We compute P(xn|xn-1), P(xn|xn-2), … iteratively
X1 X2
)|()(),( 111 xxPxPxxP nn =
X3
∑
∑
++
+
=
=+
i
i
xinii
xiniin
xxPxxP
xxxPxxP
)|()|(
)|,()|(
11
11
Xn...
Inference in Simple Chains (cont.)
• Suppose that we observe the value of Xn =xn
• We want to find P(Xk|xn )
• How do we compute P(Xk,xn )?
• We compute P(Xk ) by forward iterations
• We compute P(xn | Xk ) by backward iterations
X1 X2
)|()(),( knknk xxPxPxxP =
Xk Xn......
Elimination in Chains
• We now try to understand the simple chain example using first-order principles
• Using definition of probability, we have
∑∑∑∑=d c b a
edcbaPeP ),,,,()(
A B C ED
Elimination in Chains
• By chain decomposition, we get
A B C ED
∑∑∑∑
∑∑∑∑=
=
d c b a
d c b a
dePcdPbcPabPaP
edcbaPeP
)|()|()|()|()(
),,,,()(
Elimination in Chains
• Rearranging terms ...
A B C ED
∑∑∑ ∑
∑∑∑∑=
=
d c b a
d c b a
abPaPdePcdPbcP
dePcdPbcPabPaPeP
)|()()|()|()|(
)|()|()|()|()()(
Elimination in Chains
• Now we can perform innermost summation
• This summation, is exactly the first step in the forward iteration we describe before
A B C ED
∑∑∑
∑∑∑ ∑=
=
d c b
d c b a
bpdePcdPbcP
abPaPdePcdPbcPeP
)()|()|()|(
)|()()|()|()|()(
X
Elimination in Chains
• Rearranging and then summing again, we get
A B C ED
∑∑
∑∑ ∑
∑∑∑
=
=
=
d c
d c b
d c b
cpdePcdP
bpbcPdePcdP
bpdePcdPbcPeP
)()|()|(
)()|()|()|(
)()|()|()|()(
X X
Elimination in Chains with Evidence
• Similarly, we understand the backward pass
• We write the query in explicit form
A B C ED
∑∑∑
∑∑∑=
=
b c d
b c d
dePcdPbcPabPaP
edcbaPeaP
)|()|()|()|()(
),,,,(),(
Elimination in Chains with Evidence
• Eliminating d, we get
A B C ED
∑∑
∑∑ ∑
∑∑∑
=
=
=
b c
b c d
b c d
cePbcPabPaP
dePcdPbcPabPaP
dePcdPbcPabPaPeaP
)|()|()|()(
)|()|()|()|()(
)|()|()|()|()(),(
X
Elimination in Chains with Evidence
• Eliminating c, we get
A B C ED
∑
∑ ∑
∑∑
=
=
=
b
b c
b c
bepabPaP
cePbcPabPaP
cePbcPabPaPeaP
)|()|()(
)|()|()|()(
)|()|()|()(),(
XX
Elimination in Chains with Evidence
• Finally, we eliminate b
A B C ED
)|()(
)|()|()(
)|()|()(),(
aePaP
bepabPaP
bepabPaPeaP
b
b
=
=
=
∑
∑
XXX
Variable Elimination
General idea:• Write query in the form
• Iteratively– Move all irrelevant terms outside of innermost sum– Perform innermost sum, getting a new term– Insert the new term into the product
∑ ∑∑∏=kx x x i
iin paxPXP3 2
)|(),( Le
A More Complex Example
Visit to Asia
Smoking
Lung CancerTuberculosis
Abnormalityin Chest
Bronchitis
X-Ray Dyspnea
• “Asia” network:
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: v,s,x,t,l,a,b
Initial factors
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: v,s,x,t,l,a,b
Initial factors
Eliminate: v
Note: fv(t) = P(t)In general, result of elimination is not necessarily a probability term
Compute: ∑=v
v vtPvPtf )|()()(
),|()|(),|()|()|()()( badPaxPltaPsbPslPsPtfv⇒
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: s,x,t,l,a,b
• Initial factors
Eliminate: s
Summing on s results in a factor with two arguments fs(b,l)In general, result of elimination may be a function of several variables
Compute: ∑=s
s slPsbPsPlbf )|()|()(),(
),|()|(),|()|()|()()( badPaxPltaPsbPslPsPtfv⇒
),|()|(),|(),()( badPaxPltaPlbftf sv⇒
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: x,t,l,a,b
• Initial factors
Eliminate: x
Note: fx(a) = 1 for all values of a !!
Compute: ∑=x
x axPaf )|()(
),|()|(),|()|()|()()( badPaxPltaPsbPslPsPtfv⇒
),|()|(),|(),()( badPaxPltaPlbftf sv⇒
),|(),|()(),()( badPltaPaflbftf xsv⇒
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: t,l,a,b
• Initial factors
Eliminate: t
Compute: ∑=t
vt ltaPtflaf ),|()(),(
),|()|(),|()|()|()()( badPaxPltaPsbPslPsPtfv⇒
),|()|(),|(),()( badPaxPltaPlbftf sv⇒
),|(),|()(),()( badPltaPaflbftf xsv⇒
),|(),()(),( badPlafaflbf txs⇒
V S
LT
A B
X D
),|()|(),|()|()|()|()()( badPaxPltaPsbPslPvtPsPvP
• We want to compute P(d)• Need to eliminate: l,a,b
InducerInducerInducerInducerData + Prior information
E
R
B
A
C .9 .1
e
b
e
.7 .3
.99 .01
.8 .2
be
b
b
e
BE P(A | E,B)
Known Structure -- Complete Data
E, B, A<Y,N,N><Y,Y,Y><N,N,Y><N,Y,Y> . .<N,Y,Y>
InducerInducerInducerInducer
E B
A.9 .1
e
b
e
.7 .3
.99 .01
.8 .2
be
b
b
e
BE P(A | E,B)
? ?
e
b
e
? ?
? ?
? ?
be
b
b
e
BE P(A | E,B) E B
A
• Network structure is specified– Inducer needs to estimate parameters
• Data does not contain missing values
Unknown Structure -- Complete Data
E, B, A<Y,N,N><Y,Y,Y><N,N,Y><N,Y,Y> . .<N,Y,Y>
InducerInducerInducerInducer
E B
A.9 .1
e
b
e
.7 .3
.99 .01
.8 .2
be
b
b
e
BE P(A | E,B)
? ?
e
b
e
? ?
? ?
? ?
be
b
b
e
BE P(A | E,B) E B
A
• Network structure is not specified– Inducer needs to select arcs & estimate parameters
• Data does not contain missing values
Known Structure -- Incomplete Data
InducerInducerInducerInducer
E B
A.9 .1
e
b
e
.7 .3
.99 .01
.8 .2
be
b
b
e
BE P(A | E,B)
? ?
e
b
e
? ?
? ?
? ?
be
b
b
e
BE P(A | E,B) E B
A
• Network structure is specified• Data contains missing values
– We consider assignments to missing values
E, B, A<Y,N,N><Y,?,Y><N,N,Y><N,Y,?> . .<?,Y,Y>
Known Structure / Complete Data
• Given a network structure G– And choice of parametric family for P(Xi|Pai)
• Learn parameters for network
Goal• Construct a network that is “closest” to
probability that generated the data
Learning Parameters for a Bayesian Network
E B
A
C
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
⋅⋅⋅⋅⋅⋅⋅⋅
=
][][][][
]1[]1[]1[]1[
MCMAMBME
CABE
D
• Training data has the form:
Learning Parameters for a Bayesian Network
E B
A
C
• Since we assume i.i.d. samples,likelihood function is
∏ Θ=Θm
mCmAmBmEPDL ):][],[],[],[():(
Learning Parameters for a Bayesian Network
E B
A
C
• By definition of network, we get
∏
∏
Θ
Θ
Θ
Θ
=
Θ=Θ
m
m
mAmCP
mEmBmAP
mBP
mEP
mCmAmBmEPDL
):][|][(
):][],[|][(
):][(
):][(
):][],[],[],[():(
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
⋅⋅⋅⋅⋅⋅⋅⋅
][][][][
]1[]1[]1[]1[
MCMAMBME
CABE
Learning Parameters for a Bayesian Network
E B
A
C
• Rewriting terms, we get
∏
∏
∏
∏
∏
Θ
Θ
Θ
Θ=
Θ=Θ
m
m
m
m
m
mAmCP
mEmBmAP
mBP
mEP
mCmAmBmEPDL
):][|][(
):][],[|][(
):][(
):][(
):][],[],[],[():(
⎥⎥⎥⎥
⎦
⎤
⎢⎢⎢⎢
⎣
⎡
⋅⋅⋅⋅⋅⋅⋅⋅
][][][][
]1[]1[]1[]1[
MCMAMBME
CABE
General Bayesian Networks
Generalizing for any Bayesian network:
• The likelihood decomposes according to the structure of the network.
∏
∏∏
∏∏
∏
Θ=
Θ=
Θ=
Θ=Θ
iii
i miii
m iiii
mn
DL
mPamxP
mPamxP
mxmxPDL
):(
):][|][(
):][|][(
):][,],[():( 1 Ki.i.d. samples
Network factorization
General Bayesian Networks (Cont.)
Decomposition Independent Estimation Problems
If the parameters for each family are not related, then they can be estimated independently of
each other.
From Binomial to Multinomial
• For example, suppose X can have the values 1,2,…,K
• We want to learn the parameters 1, 2. …, K
Sufficient statistics:
• N1, N2, …, NK - the number of times each outcome is observed
Likelihood function:
MLE:
∏=
=K
k
Nk
kDL1
):(
∑=
llN
Nkk
ˆ
Likelihood for Multinomial Networks
• When we assume that P(Xi | Pai ) is multinomial, we get further decomposition:
∏∏
∏∏
∏ ∏
∏
=
Θ=
Θ=
Θ=Θ
=
i i
ii
ii
i i
ii
i ii
pa x
paxNpax
pa x
paxNiii
pa pamPamiii
miiiii
paxP
pamxP
mPamxPDL
),(|
),(
][,
):|(
):|][(
):][|][():(
θ
∏ Θ=Θm
iiiii mPamxPDL ):][|][():(
∏∏
∏ ∏
∏
Θ=
Θ=
Θ=Θ
=
i i
ii
i ii
pa x
paxNiii
pa pamPamiii
miiiii
paxP
pamxP
mPamxPDL
),(
][,
):|(
):|][(
):][|][():(
∏ ∏
∏
=
Θ=
Θ=Θ
i iipa pamPamiii
miiiii
pamxP
mPamxPDL
][,
):|][(
):][|][():(
Likelihood for Multinomial Networks
• When we assume that P(Xi | Pai ) is multinomial, we get further decomposition:
• For each value pai of the parents of Xi we get an independent multinomial problem
• The MLE is
∏∏=Θi i
ii
iipa x
paxNpaxii DL ),(
|):( θ
)(),(ˆ
|i
iipax paN
paxNii=
Maximum Likelihood Estimation
Consistency • Estimate converges to best possible value as the
number of examples grow
• To make this formal, we need to introduce some definitions
KL-Divergence
• Let P and Q be two distributions over X• A measure of distance between P and Q is the
Kullback-Leibler Divergence
• KL(P||Q) = 1 (when logs are in base 2) =– The probability P assigns to an instance is, on
average, half the probability Q assigns to it
• KL(P||Q) 0 • KL(P||Q) = 0 iff are P and Q equal
∑=x )x(Q
)x(Plog)x(P)Q||P(KL
Consistency
• Let P(X| ) be a parametric family– We need to make various regularity condition we won’t go
into now
• Let P*(X) be the distribution that generates the data
• Let be the MLE estimate given a dataset D
Thm• As N , where
with probability 1
D̂
*ˆ →D
):X(P||)X(P(KLminarg ** =
Consistency -- Geometric Interpretation
P*
P(X| * )
Space of probability distribution
Distributions that canrepresented by P(X| )
Bayesian Inference
Frequentist Approach:• Assumes there is an unknown but fixed parameter • Estimates with some confidence • Prediction by using the estimated parameter value
Bayesian Approach:• Represents uncertainty about the unknown
parameter• Uses probability to quantify this uncertainty:
– Unknown parameters as random variables
• Prediction follows from the rules of probability:– Expectation over the unknown parameters
Bayesian Inference (cont.)
• We can represent our uncertainty about the sampling process using a Bayesian network
• The values of X are independent given
• The conditional probabilities, P(x[m] | ), are the parameters in the model
• Prediction is now inference in this network
X[1] X[2] X[m] X[m+1]
Observed data Query
Bayesian Inference (cont.)
Prediction as inference in this network
where
+=
+=
+
∫∫
dMxxPMxP
dMxxPMxxMxP
MxxMxP
])[,],1[|()|]1[(
])[,],1[|(])[,],1[,|]1[(
])[,],1[|]1[(
K
KK
K
])[],1[()()|][],1[(
])[],1[|(MxxP
PMxxPMxxP
KK
K=
Posterior
Likelihood Prior
Probability of data
X[1] X[2] X[m] X[m+1]
Dirichlet Priors
• Recall that the likelihood function is
• A Dirichlet prior with hyperparameters 1,…,K is defined as
for legal 1,…, K
Then the posterior has the same form, with
hyperparameters 1+N 1,…,K +N K
∏=
=ΘK
1k
Nk
kDL θ):(
∏=
−∝ΘK
kk
kP1
1)(
∏∏∏=
−+
==
− =∝ΘΘ∝ΘK
k
Nk
K
k
Nk
K
kk
kkkkDPPDP1
1
11
1)|()()|( αα θθθ
Dirichlet Priors (cont.)
• We can compute the prediction on a new event in closed form:
• If P( ) is Dirichlet with hyperparameters 1,…,K then
• Since the posterior is also Dirichlet, we get
∑∫
=ΘΘ⋅==
ll
kk d)(P)k]1[X(P
∑∫ ++
=ΘΘ⋅==+
lll )N(
Nd)D|(P)D|k]1M[X(P kk
k
Prior Knowledge
• The hyperparameters 1,…,K can be thought of as “imaginary” counts from our prior experience
• Equivalent sample size = 1+…+K
• The larger the equivalent sample size the more confident we are in our prior
Bayesian Prediction(cont.)
• Given these observations, we can compute the posterior for each multinomial Xi | pai
independently– The posterior is Dirichlet with parameters
• The predictive distribution is then represented by the parameters
)pa(N)pa()pa,x(N)pa,x(~
ii
iiiipa|x ii +
+=
Learning Parameters: Summary
• Estimation relies on sufficient statistics– For multinomial these are of the form N (xi,pai)
– Parameter estimation
• Bayesian methods also require choice of priors• Both MLE and Bayesian are asymptotically
equivalent and consistent• Both can be implemented in an on-line manner
by accumulating sufficient statistics
)()(),(),(~
|ii
iiiipax paNpa
paxNpaxii +
+=
)(),(ˆ
|i
iipax paN
paxNii=
MLE Bayesian (Dirichlet)
Learning Structure from Complete Data
Why Struggle for Accurate Structure?
• Increases the number of parameters to be fitted
• Wrong assumptions about causality and domain structure
• Cannot be compensated by accurate fitting of parameters
• Also misses causality and domain structure
Earthquake Alarm Set
Sound
BurglaryEarthquake Alarm Set
Sound
Burglary
Earthquake Alarm Set
Sound
Burglary
Adding an arc Missing an arc
Approaches to Learning Structure
• Constraint based– Perform tests of conditional independence– Search for a network that is consistent with the
observed dependencies and independencies
• Pros & Cons Intuitive, follows closely the construction of BNs Separates structure learning from the form of the
independence tests Sensitive to errors in individual tests
Approaches to Learning Structure
• Score based– Define a score that evaluates how well the (in)dependencies
in a structure match the observations– Search for a structure that maximizes the score
• Pros & Cons Statistically motivated Can make compromises Takes the structure of conditional probabilities into account Computationally hard
Likelihood Score for Structures
First cut approach: – Use likelihood function
• Recall, the likelihood score for a network structure and parameters is
• Since we know how to maximize parameters from now we assume
∏∏
∏Θ=
Θ=Θ
m ii,G
Gii
mGn1G
),G:]m[Pa|]m[x(P
),G:]m[x,],m[x(P)D:,G(L K
):,(max):( DGLDGL GGΘ= Θ
Avoiding Overfitting
“Classic” issue in learning. Approaches:• Restricting the hypotheses space
– Limits the overfitting capability of the learner– Example: restrict # of parents or # of parameters
• Minimum description length– Description length measures complexity– Prefer models that compactly describes the training data
• Bayesian methods– Average over all possible parameter values– Use prior knowledge
Bayesian Inference
• Bayesian Reasoning---compute expectation over unknown G
• Assumption: Gs are mutually exclusive and exhaustive
• We know how to compute P(x[M+1]|G,D)– Same as prediction with fixed structure
• How do we compute P(G|D)?
∑ +=+G
)D|G(P)G,D|]1M[x(P)D|]1M[x(P
Marginal likelihood
Prior over structures
)()()|(
)|(DP
GPGDPDGP =
Using Bayes rule:
P(D) is the same for all structures GCan be ignored when comparing structures
Probability of Data
Posterior Score
Marginal Likelihood
• By introduction of variables, we have that
• This integral measures sensitivity to choice of parameters
∫= dGPGDPGDP )|(),|()|(
LikelihoodPrior over parameters
Marginal Likelihood: Multinomials
The same argument generalizes to multinomials with Dirichlet prior
• P( ) is Dirichlet with hyperparameters 1,…,K
• D is a dataset with sufficient statistics N1,…,NK
Then
∏∑
∑Γ
+Γ
⎟⎠
⎞⎜⎝
⎛+Γ
⎟⎠
⎞⎜⎝
⎛Γ
=l l
ll
lll
ll
)()(
)()(
αα
α
αN
NDP
Marginal Likelihood for General Network
The marginal likelihood has the form:
where • N(..) are the counts from the data (..) are the hyperparameters for each family
given G
( )( )∏∏ ∏ Γ
+Γ
+Γ
Γ=
i pa xG
i
Gi
Gi
GG
G
Gi i i
ii
ii
i
pax
paxNpax
paNpa
paGDP
)),((
)),(),((
)()(
)()|(
α
α
α
α
Dirichlet Marginal LikelihoodFor the sequence of values of Xi when
Xi’s parents have a particular value
Priors
• We need: prior counts (..) for each network structure G
• This can be a formidable task– There are exponentially many structures…
BDe Score
Possible solution: The BDe prior
• Represent prior using two elements M0, B0
– M0 - equivalent sample size
– B0 - network representing the prior probability of events
BDe Score
Intuition: M0 prior examples distributed by B0
• Set (xi,paiG) = M0 P(xi,pai
G| B0) – Note that pai
G are not the same as the parents of Xi in B0.
– Compute P(xi,paiG| B0) using standard inference
procedures
• Such priors have desirable theoretical properties– Equivalent networks are assigned the same score
Bayesian Score: Asymptotic Behavior
Theorem: If the prior P(Θ |G) is “well-behaved”, then
)1()dim(2
log):()|(log OG
MDGlGDP +−=
Asymptotic Behavior: Consequences
• Bayesian score is consistent– As M the “true” structure G* maximizes the score
(almost surely)– For sufficiently large M, the maximal scoring
structures are equivalent to G*
• Observed data eventually overrides prior information– Assuming that the prior assigns positive probability to
all cases
)1()dim(2
log):()|(log OG
MDGlGDP +−=
Asymptotic Behavior
• This score can also be justified by the Minimal Description Length (MDL) principle
• This equation explicitly shows the tradeoff between– Fitness to data --- likelihood term– Penalty for complexity --- regularization term
)dim(2
log):():Score( G
MDGlDG −=
Scores -- Summary
• Likelihood, MDL, (log) BDe have the form
• BDe requires assessing prior network.It can naturally incorporate prior knowledge and previous experience
• BDe is consistent and asymptotically equivalent (up to a constant) to MDL
• All are score-equivalent– G equivalent to G’ Score(G) = Score(G’)
))(:|():( iii
Gi PaXNPaXScoreDGScore
i∑=
Optimization Problem
Input:– Training data– Scoring function (including priors, if needed)– Set of possible structures
• Including prior knowledge about structure
Output:– A network (or networks) that maximize the score
Key Property:– Decomposability: the score of a network is a sum of
terms.
Difficulty
Theorem: Finding maximal scoring network structure with at most k parents for each variables is NP-hard for k > 1
Heuristic Search
We address the problem by using heuristic search
• Define a search space:– nodes are possible structures– edges denote adjacency of structures
• Traverse this space looking for high-scoring structures
Search techniques:– Greedy hill-climbing– Best first search– Simulated Annealing– ...
Heuristic Search (cont.)
• Typical operations:
S C
E
D
S C
E
D
Reverse C EDelete C
E
Add C
D
S C
E
D
S C
E
D
Exploiting Decomposability in Local Search
• Caching: To update the score of after a local change, we only need to re-score the families that were changed in the last move
S C
E
D
S C
E
D
S C
E
D
S C
E
D
Greedy Hill-Climbing
• Simplest heuristic local search– Start with a given network
• empty network• best tree • a random network
– At each iteration• Evaluate all possible changes• Apply change that leads to best improvement in score• Reiterate
– Stop when no modification improves score
• Each step requires evaluating approximately n new changes
Greedy Hill-Climbing: Possible Pitfalls
• Greedy Hill-Climbing can get struck in:– Local Maxima:
• All one-edge changes reduce the score
– Plateaus:• Some one-edge changes leave the score unchanged• Happens because equivalent networks received the
same score and are neighbors in the search space
• Both occur during structure search• Standard heuristics can escape both
– Random restarts– TABU search
Model Selection
• So far, we focused on single model– Find best scoring model– Use it to predict next example
• Implicit assumption: – Best scoring model dominates the weighted
sum
• Pros:– We get a single structure– Allows for efficient use in our tasks
• Cons:– We are committing to the independencies of a
particular structure– Other structures might be as probable given the data
Model Averaging
• Recall, Bayesian analysis started with
– This requires us to average over all possible models
∑ +=+G
DGPGDMxPDMxP )|(),|]1[()|]1[(
Model Averaging (cont.)
• Full Averaging– Sum over all structures– Usually intractable---there are exponentially many structures
• Approximate Averaging– Find K largest scoring structures– Approximate the sum by averaging over their prediction– Weight of each structure determined by the Bayes Factor
)()(
)'|()'()|()(
)|'()|(
DPDP
GDPGPGDPGP
DGPDGP
⋅=
The actual score we compute
Search: Summary
• Discrete optimization problem• In general, NP-Hard
– Need to resort to heuristic search– In practice, search is relatively fast (~100 vars in ~10 min):
• Decomposability• Sufficient statistics
• In some cases, we can reduce the search problem to an easy optimization problem– Example: learning trees