Download Course Notes for Bayesian Models for Machine Learning and more Study notes Machine Learning in PDF only on Docsity!
Course Notes for
Bayesian Models for Machine Learning
John Paisley
Department of Electrical Engineering
Columbia University
Fall 2016
Contents
- Contents
- Probability review, Bayes rule, conjugate priors
- predictive distributions Bayesian linear regression, Bayes classifiers,
- matrix factorization Laplace approximation, Gibbs sampling, logistic regression,
- EM algorithm, probit regression
- EM to variational inference
- Variational inference, finding optimal distributions
- Latent Dirichlet allocation, exponential families
- conjugate exponential family models, scalable inference
- Gaussian mixture models
- Bayesian nonparametric clustering
- Hidden Markov models
- Poisson matrix factorization
- We’ve simply multiplied and divided by the same thing, but already we’ve made a general state- ment.
A more general statement
- Let A and B be two events, then
P (A|B) =
P (A, B)
P (B)
⇒ P (A|B)P (B) = P (A, B)
- We have some names for these terms,
P (A|B) : conditional probability distribution P (A, B) : joint probability distribution P (B) : marginal probability distribution
- This last one could be tricky, since it’s also just “the probability of B.” However, we can use the same counting approach as before to interpret P (B) as a distribution arrived at by integrating (or marginalizing) something out. From the previous example,
P (B) =
#B
i=1 #(Ai^ ∩^ B) #Ω
∑^3
i=
#(Ai ∩ B) #Ω
∑^3
i=
P (Ai, B)
- Side note: In general, the summation and each Ai have a very strict requirement. Each Ai has to be disjoint (no overlaps) and the union of all the Ai has to equal Ω (the entire space).
Getting to Bayes rule
- We’re a few easy steps away. We showed that
P (A, B) = P (A|B)P (B)
By symmetry we could just as easily have shown that
P (A, B) = P (B|A)P (A)
And therefore,
P (A|B) =
P (B|A)P (A)
P (B)
P (B|A)P (A)
i P^ (Ai, B)^
P (B|A)P (A)
i P^ (B|Ai)P^ (Ai)
- This equality is called Bayes rule. As you can see, it has a few ways it can be written.
Bayes rule
- And so we have that P (A|B) =
P (B|A)P (A)
P (B)
- These values each have a name:
posterior =
likelihood × prior evidence
- Imagine that we don’t know A, but we get some information about it in the form of B. Bayes rule tells us a principled way to incorporate this information in our belief about A.
Example (medical test)
- We have two binary values, A and B:
A =
1 person has disease 0 no disease
B =
1 test for disease “positive” 0 test is “negative”
- A person tests “positive” for the disease. What’s the probability he has it?
- We want P (A = 1|B = 1). Does Bayes rule help? Bayes rule says that
P (A = 1|B = 1) =
P (B = 1|A = 1)P (A = 1)
P (B = 1)
P (B = 1|A = 1)P (A = 1)
P (B = 1|A = 1)P (A = 1) + P (B = 1|A = 0)P (A = 0)
- Image we can estimate that
P (B = 1|A = 1) = 0. 95 , P (B = 1|A = 0) = 0. 05 , P (A = 1) = 0.01 = 1 − P (A = 0)
Then plugging in, we have that P (A = 1|B = 1) = 0. 16
Continuous space
- We’ve been talking about discrete distributions so far. That is, the number of possible values the unknowns can take is finite.
- When values are in a continuous space, we switch to continuous distributions.
Example
x ∈ R, p(x) is its density (represented by the switch to lower case)
p(x) ≥ 0 and
p(x)dx = 1
P (x ∈ A) =
A p(x)dx
- The same rules apply as for discrete random variables
- We further assume the Xi are independent and identically distributed (iid). This means the Xi are conditionally independent given π. Mathematically this means we can write
P (X 1 ,... , XN |π) =
∏^ N
i=
P (Xi|π)
- Since P (Xi|π) = πXi^ (1 − π)^1 −Xi^ , we can write
P (X 1 ,... , XN |π) =
∏^ N
i=
πXi^ (1 − π)^1 −Xi
- We are interested in the posterior distribution of π given X 1 ,... , XN , i.e.,
P (π|X 1 ,... , XN ) ∝ P (X 1 ,... , XN |π)p(π)
∝
∏^ N
i=
πXi^ (1 − π)^1 −Xi^ p(π)
- We’ve come across the next significant problem: What do we set p(π) to?
A first try
- Let p(π) = U nif orm(0, 1) ⇒ p(π) = 1 (0 ≤ π ≤ 1)
- Then by Bayes rule,
p(π|X 1 ,... , XN ) =
π(
∑ i Xi+1)−^1 (1 − π)(N^ −
∑ i Xi+1)−^1 ∫ (^1) 0 π
∑ i Xi^ (1 − π)N^ −
∑ i Xi^ dπ
- The normalizing constant is tricky, but fortunately mathematicians have solved it,
p(π|X 1 ,... , XN ) =
Γ(N + 2)
i Xi)Γ(1 +^ N^ −^
i Xi)
π
∑ i Xi+1−^1 (1 − π)N^ −
∑ i Xi+1−^1
(Γ(·) is called the “gamma function”)
- This is a very common distribution called a beta distribution:
Beta(a, b) =
Γ(a + b) Γ(a)Γ(b)
πa−^1 (1 − π)b−^1
- In the case of the above posterior distribution, a = 1 +
i Xi^ and^ b^ = 1 +^ N^ −^
i Xi.
- Notice that when a = b = 1, Beta(1, 1) = U nif orm(0, 1) which was the prior we chose.
A conjugate prior
- The beta distribution looks a lot like the likelihood term. Also, because it has the U nif orm(0, 1) distribution as a special case, it would give us a wider range of prior beliefs that we could express. What if we try the beta distribution as the prior for π?
p(π|X 1 ,... , XN ) ∝ p(X 1 ,... , XN |π)p(π)
[
π
∑ i Xi^ (1 − π)N^ −
∑ i Xi
][ (^) Γ(a + b) Γ(a)Γ(b)
πa−^1 (1 − π)b−^1
]
∝ πa+
∑ i Xi−^1 (1 − π)b+N^ −
∑ i Xi−^1
- We can notice a few things here:
- I threw away (^) Γ(Γ(aa)Γ(+bb)) in the last line. This is because it doesn’t depend on π, and so it can be absorbed in the normalizing constant. In other words, the normalizing constant is the integral of the numerator. If we divide the second line by this integral, we can immediately cancel out (^) Γ(Γ(aa)Γ(+bb)). The result is the third line divided by the integral of the third line. The only reason to do something like this is for convenience and to make things look simpler.
- In this case, we know what to divide this by to make it a probability distribution on π. The last line is proportional to a Beta(a +
i Xi, b^ +^ N^ −^
i Xi)^ distribution.
- Therefore, p(π|X 1 ,... , XN ) = Beta(a +
i Xi, b^ +^ N^ −^
i Xi).
- Notice that for this problem, when we select the prior p(π) to be a beta distribution, we find that the posterior distribution is also a beta distribution with different parameters. This is because the beta distribution is a conjugate prior for this problem.
- We say that a distribution is a “conjugate prior” for a particular variable in a likelihood, or that it is “conjugate to the likelihood,” if the posterior is in the same distribution family as the prior, but has updated parameters. Conjugate priors are very convenient, since we only need to collect sufficient statistics from the data in order to transition from the prior to the posterior. For example, in the problem above we only need to count the total number of “successes” (
i Xi) and “failures” (N −
i Xi).
- will see many conjugate priors in this course and how they can result in fast inference algorithms for learning models.
What do we gain by being Bayesian?
- For the previous modeling problem with a beta prior, consider the expectation and variance of π under the posterior distribution.
E[π] =
a +
i Xi a + b + N
, V ar(π) =
(a +
i Xi)(b^ +^ N^ −^
i Xi) (a + b + N )^2 (a + b + N − 1)
EECS E6720 Bayesian Models for Machine Learning
Columbia University, Fall 2016
Lecture 2, 9/15/
Instructor: John Paisley
- Next, we look at another instance of a conjugate prior. To help motivate the practical usefulness of the distributions we will consider, we discuss this prior in the context of a regression problem.
Problem setup
- We’re often given a data set of the form D = {(xi, yi)}Ni=1 where x ∈ Rd^ and y ∈ R. The goal is to learn a prediction rule from this data so that, given a new xˆ we can predict its associated an unobserved yˆ. This is called a regression problem.
- We often refer to x as “covariates” or “features” and y as a “response.”
Linear regression
- One model for this problem is to assume a linear relationship between the inputs x and outputs y such that yi = xTi w + i The term i accounts for the fact that we usually can’t find a w such that yi = xTi w for all i. The model value of interest is w and we simply set i = yi − xTi w. Further assumptions let w ∈ Rd and i iid ∼ Normal(0, σ^2 ).
Likelihood term for y
- Using only this information, we have an implied likelihood term of y given X and w (where X = {xi}).
- First, notice that for each i
yi ind ∼ Normal(xTi w, σ^2 )
where we recall that Normal(yi|xTi w, σ^2 ) = (2πσ^2 )
1 (^2) exp{− (^2) σ^12 (yi − xTi w)^2 }.
- Because of the conditional independence assumption of yi given w, we can write the likelihood as
p(y 1 ,... , yN |w, X) =
∏^ N
i=
p(yi|w, xi)
- The vector w is the model parameter that is unknown as we want to learn it. Bayesian linear regression takes the additional step of treating w as a random variable with a prior distribution. Hence in the Bayesian setting we refer to w as a model variable instead of a model parameter.
- After defining a prior p(w), we use Bayes rule to learn a posterior distribution on w:
p(w|X, ~y) =
p(~y|X, w)p(w) ∫ Rd^ p(~y|X, w)p(w)dw^
∏N
∫ i=1^ p(yi|xi, w)p(w) Rd
∏N
i=1 p(yi|xi, w)p(w)dw
- Question: Why is X always being conditioned on? (i.e., on the RHS of | )
- Answer: Look at what we have distributions on.
- The model assumes a generative distribution for y
- We put a prior distribution on w
- We haven’t assumed any distribution on xi
- In short, this results from the model assumptions that we have made
Prior on w
- We still have to define the prior distribution on w. Out of convenience we define
w ∼ Normal(0, λ−^1 I)
Why do we do this? Because it’s conjugate to the likelihood. As a result, the posterior distribution of w is a recogniz- able distribution with known parameters that can be easily calculated from the data.
Posterior of w
- We next calculate the posterior distribution of w for this model. The steps we take are as follows:
Using Bayes rule we have that
p(w|X, ~y) ∝
∏^ N
i=
Normal(yi|xTi w, σ^2 )Normal(w| 0 , λ−^1 I)
By direction plugging in using the form of a Gaussian, we have that
p(w|X, ~y) ∝
[ ∏N
i=
e−^
1 2 σ^2 (yi−x Ti w) 2 ][ e−^
λ 2 wT (^) w^ ]
- Finally, we want to calculate p(w|X, ~y) exactly. We’re hoping we can find a closed form solution to the integral in
p(w|X, ~y) =
exp
− 12 (w − μ)T^ Σ−^1 (w − μ)
exp
− 12 (w − μ)T^ Σ−^1 (w − μ)
dw
where I use the same definition of μ and Σ as in Step 5. Approaching this problem from a purely mathematical standpoint, this is not easy at all. However, mathematicians and statisticians have been collecting known probability distributions for our reference. At some point, someone actually solved this integral and now we have the solution without having to recalculate the integral each time.
Specifically, we know that a d-dimensional multivariate Gaussian distribution with mean μ and covariance Σ has the form
p(w|μ, Σ) = (2π)−^
d 2 |Σ|−^
(^12) e−^
(^12) (w−μ)T (^) Σ− (^1) (w−μ)
We know from other people’s calculations that this function of w integrates to 1. This function is also proportional to the function in Step 5. In Step 6 we’re solving the integral in order to find the constant to multiply Step 5 with to make the function integrate to 1. Therefore, we know this constant is (2π)−^ d 2 |Σ|−^ (^12) and ∫ exp
− 12 (w − μ)T^ Σ−^1 (w − μ)
dw = (2π) d 2 |Σ| (^12)
It’s an argument based on logic and based on trust that previous proofs that the nonnegative function (2π)−^
d 2 |Σ|−^
(^12) e−^
(^12) (w−μ)T (^) Σ− (^1) (w−μ) integrates to 1 are correct, which is the stopping point for this class (and 99.99% of all “Bayesians” including myself).
- Therefore, we have shown that the posterior distribution p(w|X, ~y) is a multivariate Gaus- sian with mean μ and covariance Σ, where
Σ = (λI + (^) σ^12
i xix
T i ) − (^1) μ = Σ( 1 σ^2
i yixi) Notice that this is in the same family as the prior p(w), which was also a multivariate Gaussian. Therefore we chose a conjugate prior for w.
Making predictions
- For many applications, the posterior distribution of a model’s variables gives useful information. For example, it often provides information on the structure underlying the data, or cause and effect type relationships.
- For example, in the linear regression model y = xT^ w + we’ve been discussing, the vector w tells us the relationship between the inputs of x and output y. e.g., if wk is positive the model will lead us to believe that increasing the kth dimension of x will increase y and by how much. We might then use this information to figure out which dimensions we need to “improve.”
- Often, however, we just want to make predictions on new data using the model of the old data.
Predictive distribution
- For Bayesian linear regression, we ultimately want to predict a new yˆ given its associated xˆ and all previously observed (x, y) pairs. In other words, we wish to form the predictive distribution
p(ˆy|x, ~ˆy, X) =
Rd
p(ˆy|x, wˆ )p(w|~y, X)dw
- Notice that the predictive distribution can be written as a marginal distribution over the model variables.
- However, implied in the left hand side is the model definition, which tells us which variables to integrate over on the right hand side, as well as the specific distributions to plug in.
- That is, just writing a predictive distribution p(ˆy|x, ~ˆy, X) is not enough information to know how to represent it as a marginal distribution, where marginalization (i.e., integration) takes place over the model variables. It is necessary to know in advance what the underlying model is in order to know what model variables to integrate over.
- Let’s step back and think more generally about what we’re doing when we construct a predictive probability distribution.
Bayesian model: The Bayesian modeling problem is summarized in the following sequence.
Model of data: X ∼ p(X|θ) Model prior: θ ∼ p(θ) Model posterior: p(θ|X) = p(X|θ)p(θ)/p(X)
Predictions: The goal of making predictions is to use past data to predict the future under the same modeling assumption. This is why we choose to model data in the first place: We assume there is an underlying rule governing the way data is created whether its seen or unseen data. By defining a model we define a rule. Seeing some data lets us get a better sense of what that rule should be, letting us learn from the past. Therefore, when making predictions we assume future data follows the same rule as past data,
Future data: xˆ ∼ p(x|θ) ← the same model as the past data
We don’t know θ, but the past data X, along with our prior believe about θ, gives us information about it. In fact we have a posterior distribution on it p(θ|X). We can use this to “score” or “weight” each possible setting of θ. This is the marginalization procedure,
Predictive distribution: p(ˆx|X) =
p(ˆx|θ)p(θ|X)dθ
So by marginalizing, we are considering the infinite number of possible settings for θ in the likelihood and weighting it by our posterior belief of how probable that setting is. For certain probability distributions, we can solve this integral analytically.
- As a result, we have calculated that
p(ˆy|x, ~ˆy, X) = (2π)−^
(^12) (σ^2 + ˆxT^ Σˆx)−^
(^12) e − (^) 2(σ (^2) +ˆ^1 xT (^) Σˆx) (ˆy−ˆxT^ μ)^2
Notice that this is a univariate Normal distribution with mean ˆxT^ μ and variance σ^2 + ˆxT^ Σˆx. Again, the terms μ and Σ are calculated using the prior parameters and the data ~y and X.
Another modeling example
- Let’s look at another Bayesian modeling example that is slightly more complicated.
Problem setup
- Again we’re given a data set D = {(xi, yi)}Ni=1 where x ∈ Ωx, which is an arbitrary space, and this time y ∈ { 0 , 1 }. The goal is to classify a new x by assigning a label to it. That is, we want to predict the unknown value of y ∈ { 0 , 1 } associated with a new input x.
Bayesian classifier model
- This approach to classification assumes a generative process for both y and x. For the model, we will assume that each (x, y) pair is generated i.i.d. as follows
Model: y iid ∼ Bernoulli(π), x|y ind ∼ p(x|θy)
To draw x, we need to know y, which is what x|y is meant to convey.
- As is evident, the joint distribution on (x, y) is not a distribution that can be factorized into separate distributions on x and y. Rather, it must be factorized as
p(x, y|Θ, π) = p(x|y, Θ)p(y|π)
This factorization says that we can first sample a value for y without knowing x, after which we sample x from a distribution that depends on the value of y and some parameters Θ. This is also what the generative process above says. In fact, there we further assume Θ = {θ 0 , θ 1 } and let y pick out the correct parameters from this set.
- We can think of this as follows, imagine x contains the text of an email and y indicates whether it is spam or not. The generative model assumes that spam and non-spam emails are generated from the same distribution family, but with different parameters. All spam emails share one parameter, θ 1 , and all non-spam emails share another parameter θ 0. The data is generated by first choosing whether a spam or non-spam email will be generated by flipping a coin with bias π, and then generating the email itself from a distribution using the class-specific parameter.
- It should be clear that x doesn’t have to be an email, but something else, for example several statistics from a patient during a health checkup that can be used to diagnose an illness. The x for this problem will be in a different domain than for the email problem, which is why it is beneficial to keep the distribution and space of x general.
Prior distributions
- The model variables are the class probability π ∈ (0, 1) and class-specific variables θ 1 , θ 0. We next choose prior distributions for these. We select for π out of convenience and write a generic prior for each θ π ∼ Beta(a, b), θ 0 , θ 1 iid ∼ p(θ) We are making one assumption here about θ, that the class-specific variables are drawn indepen- dently from the same prior distribution. This will let us simplify the joint likelihood of the model for posterior computation.
Posterior computation
- Again we want to find the posterior, but this time of π, θ 0 and θ 1. Using Bayes rule,
p(π, θ 1 , θ 0 |~y, X) =
p(X, ~y|π, θ 1 , θ 0 )p(π, θ 1 , θ 0 ) ∫ Ωθ
Ωθ
0 p(X, ~y|π, θ^1 , θ^0 )p(π, θ^1 , θ^0 )dπdθ^1 dθ^0
- This time we have three variables instead of one. However, looking closer we will see that these distributions factorize nicely. (This is the exception, not the rule.)
- Prior: The prior can be written p(π, θ 1 , θ 0 ) = p(π)p(θ 1 )p(θ 0 ). Of course p(θ 1 ) and p(θ 0 ) are the same exact distribution, but evaluated at different points.
- Likelihood: By the modeling assumption, we can write the likelihood as
p(X, ~y|π, θ 1 , θ 0 ) =
∏^ N
i=
p(xi, yi|π, θ 1 , θ 0 )
∏^ N
i=
p(xi|yi, π, θ 1 , θ 0 )p(yi|π, θ 1 , θ 0 )
∏^ N
i=
p(xi|θyi )p(yi|π)
The product is from the independence assumption. The transition from the first to second line is a rule of probability that’s always true. The transition from the second to third line simplifies the to reflect the dependence structure assumed by the model.
- Finally, we can return to Bayes rule and try computing it. In the numerator, we group the multiplications across the three variables
p(π, θ 1 , θ 0 |~y, X) ∝
[
i:yi=
p(xi|θ 1 )p(θ 1 )
] [
i:yi=
p(xi|θ 0 )p(θ 0 )
] [ N
i=
p(yi|π)p(π)
]
- Spam detection: To make this more concrete, consider the problem of spam detection. In the spam detector model we will consider here, a pair (x, y) consists of a label y ∈ { 0 , 1 } indicating “spam” or “not spam” and x is a v dimensional vector of word counts for a vocabulary of size v. Thus x(j) is a count of how many times word j (e.g., j maps to “deal”) appears in the email. We need to define a distribution on x as its model, which can also be thought of as a joint probability distribution on all the values in x, p(x|θ) ⇔ p(x(1),... , x(v)|θ)
Naive Bayes takes the additional modeling step of breaking the correlation structure between these values
p(x(1),... , x(v)|θ) =
∏^ v
j=
p(x(j)|θ(j)) ← a modeling assumption – we define this
From a generative perspective, we are saying that for an observation xi, each “piece” of xi is generated independently from its own distribution given its class. The assumption that xi(j) and xi(j′) are independent given its class variable θyi is what is “naive” about this model.
We use Bayes rule to calculate the posterior of π exactly as before. Using it to calculate the pos- terior of each θy can be split into the process of calculating the posterior of each θy(j) separately. For example, in spam detection we can define p(x(j)|θy(j)) to be a Poisson distribution, and p(θy(j)) to be a gamma distribution. These two distributions are conjugate and so the posterior of θy(j) will also be gamma. Because of independence assumptions, solving for the posterior of θy can be separated into v independent applications of Bayes rule, one for each θy(j).
Predictive distribution
- As with Bayesian linear regression, a major application of the Bayes classifier is to predicting the labels of new data. That is, given a training set D = {(xi, yi)}Ni=1 of labeled data we want to learn a model so that we can predict the unobserved label yˆ ∈ { 0 , 1 } of a newly observed ˆx.
- Again we want to form the predictive distribution p(ˆy|x, X, ~ˆ y). This can be done, but is not as straightforward as before. We’ll try two ways. The first way will lead to a dead-end. The second approach will work.
First attempt
p(ˆy|ˆx, X, ~y) =
Ωθ
Ωθ
0
p(ˆy|ˆx, θ 1 , θ 0 , π)p(θ 1 , θ 0 , π|X, ~y)dπdθ 1 dθ 0
There are two distributions we need to know. The second one is the posterior that we previously calculated and showed for this model can be factorized as p(θ 1 , θ 0 , π|X, ~y) = p(θ 1 |X, ~y)p(θ 0 |X, ~y)p(π|~y) The first term is trickier and we can’t simply follow the procedure for the Bayesian linear regres- sion model. The reason is that we are asked for a distribution on yˆ conditioned on both π and ˆx plus the class-specific variables. However, according to our model we have y ∼ Bernoulli(π), x|y ∼ p(x|θy)
The generative model for the data gives us a marginal distribution on y and a conditional distri- bution on x. Therefore, unlike before we can’t just go to the model to find out what to plug in for p(ˆy|ˆx, θ 1 , θ 0 , π). However, we notice that these distributions in combination with Bayes rule provide us with all the information we need.
- The distribution p(ˆy|ˆx, θ 1 , θ 0 , π) can be interpreted as the posterior distribution of yˆ given xˆ and the model variables. By Bayes rule,
p(ˆy|x, θˆ 1 , θ 0 , π) =
p(ˆx|θyˆ)p(ˆy|π) p(ˆx|θ 1 )p(ˆy = 1|π) + p(ˆx|θ 0 )p(ˆy = 0|π)
Notice that because yˆ is a discrete variable, the integral turns into a sum over the set of possible values yˆ can take.
- We can swap p(ˆy|x, θˆ 1 , θ 0 , π) with the Bayes rule version of it in the integral to form the predictive distribution. We’re left with
p(ˆy|x, X, ~ˆ y) =
Ωθ
Ωθ
0
p(ˆx|θˆy)p(ˆy|π)p(θ 1 |X, ~y)p(θ 0 |X, ~y)p(π|~y) p(ˆx|θ 1 )p(ˆy = 1|π) + p(ˆx|θ 0 )p(ˆy = 0|π)
dπdθ 1 dθ 0
However, we now hit a dead end. Even though we have actual functions we can plug in every- where, the problem now is that there is a sum in the denominator. For example, if we plug in the functions involving π we can see that the integral is not tractable for this variable and so we can’t get an analytic function for the predictive distribution.
Second attempt
- Even though the first attempt didn’t work, we still have other options. We first notice that y ˆ ∈ { 0 , 1 }, meaning we can only query the predictive distribution at these two values. Above we used Bayes rule to make progress toward the final calculation. Now we use it again, but on the marginal distribution itself:
p(ˆy|x, X, ~ˆ y) =
p(ˆx|y, X, ~ˆ y)p(ˆy|X, ~y) p(ˆx|yˆ = 1, X, ~y)p(ˆy = 1|X, ~y) + p(ˆx|yˆ = 0, X, ~y)p(ˆy = 0|X, ~y)
p(ˆx|y, X, ~ˆ y)p(ˆy|~y) p(ˆx|yˆ = 1, X, ~y)p(ˆy = 1|~y) + p(ˆx|yˆ = 0, X, ~y)p(ˆy = 0|~y)
- Again we need to know what to plug in for the likelihood p(ˆx|y, X, ~ˆ y) and prior p(ˆy|~y). The first thing we should think is that these are both marginal distributions and can be represented as an integral over model variables.
- Likelihood: First,
p(ˆx|ˆy, X, ~y) =
Ωθ
Ωθ
p(ˆx|y, θˆ 1 , θ 0 )p(θ 1 , θ 0 |X, ~y)dθ 1 dθ 0
Ωθ
p(ˆx|θyˆ)p(θˆy|{xi : yi = ˆy})dθyˆ
Notice that π isn’t involved because, according to the model, conditioned on yˆ, xˆ is independent of π. Also, the second line shows how yˆ really picks out either θ 1 or θ 0 and so we only need to