Conditional probability for classification In Book "Machine Learning: A probabilistic Perspective" Page 30, it tries to give a generative classifiers solution using conditional probability as
$$p(y=c|x,\theta)=\frac{p(y=c|\theta)p(x|y=c,\theta)}{\sum_{c'}p(y=c'|\theta)p(x|y=c',\theta)}$$
I understand the numerator but I don't understand the denominator. How did they come to that?
 A: This is a consequence of Bayes rule $$P(A\vert B ) = \frac{P(A \cap B)}{P(B)} $$
Note for the numerator that 
$$p(y=c|\theta)p(x|y=c,\theta) = \frac{P(y = c \cap \theta)}{P(\theta)} \frac{P(x , y=c, \theta)}{P(y = c \cap \theta)} = \frac{P(x , y=c, \theta)}{P(\theta)}$$
the denominator is 
$$\sum_{c'}p(y=c'|\theta)p(x|y=c',\theta)= \sum_{c'}\frac{P(y = c' \theta)}{P(\theta)} \frac{P(x, y = c', \theta)}{P(y = c'\theta)} = \sum_{c'}\frac{P(x, y = c', \theta)}{P(\theta)}  = \frac{P(x, \theta)}{P(\theta)}  $$
Now take the quocient
$$p(y=c|x,\theta)=\frac{p(y=c|\theta)p(x|y=c,\theta)}{\sum_{c'}p(y=c^{'}|\theta)p(x|y=c^{'},\theta)} = \frac{P(x , y=c, \theta)}{P(x,\theta)}$$
As you would like to see
A: \begin{align*}
p(y=c|x,\theta) &= \frac{p(x|y=c,\theta)p(y=c|\theta)}{p(x|\theta)} \tag{Bayes' rule}\\
&= \frac{p(x|y=c,\theta)p(y=c|\theta)}{\sum_{c'}p(x,y=c'|\theta)} \tag{Law of total probability}\\
&= \frac{p(x|y=c,\theta)p(y=c|\theta)}{\sum_{c'}p(y=c'|\theta,x)p(x|\theta,y=c')}
\end{align*}
A: Starting from the definition of a conditional probability using Bayes' rule
$$p(y=c|x,\theta)=\frac{\color{blue}{p(y=c,x,\theta)}}{p(x,\theta)}=\frac{\color{blue}{p(x|y=c,\theta)p(y=c|\theta)p(\theta)}}{p(x,\theta)}$$
where we use the chain rule in the numerator (parts highlighted in blue), to express the joint density as a product of the conditional densities.  
The denominator is $p(x,\theta)$, which can be expressed as the marginal of the joint density $p(x,\theta,y=c')$ integrated over $y$ 
$$p(x,\theta)=\sum_{y}p(x,\theta,y=c')$$
using the chain rule of conditional densities we express $p(x,\theta,y=c')$ as $$p(x,\theta,y=c')=p(x|\theta,y=c')p(y=c'|\theta)p(\theta)$$
Combining these rules leads to 
$$\begin{align}p(x,\theta)&=\sum_{y\in c'}p(x,\theta,y=c')\\&=\sum_{y\in c'}p(x|\theta,y=c')p(y=c'|\theta)p(\theta)
\\&=p(\theta)\sum_{y\in c'}p(x|\theta,y=c')p(y=c'|\theta)\end{align}$$
Finally, given the numerator and denominator, we have the desired expression (note the cancellation of the $p(\theta)$ terms):-
$$\begin{align}p(y=c|x,\theta)&=\frac{p(x|y=c,\theta)p(y=c|\theta)p(\theta)}{p(\theta)\sum_{y\in c'}p(x|\theta,y=c')p(y=c'|\theta)}\\&=\frac{p(x|y=c,\theta)p(y=c|\theta)}{\sum_{y\in c'}p(x|\theta,y=c')p(y=c'|\theta)}\end{align}$$
A: *

*When Andrea needs a taxi, she rings one of three taxi companies, A, B or C. 50% of her calls are to taxi company A, 30% to B and 20% to C. A taxi from company A arrives late 4% of the time, a taxi from company B arrives late 6%of the time and a taxi from company C arrives late 17% of the time.

