In cs229, the problem set1 of 2019 summer, question 2(e):
why $p(y^{(i)}=1)$ equal to $E[p(y^{(i)}=1|x^{(i)})]$ ?
In cs229, the problem set1 of 2019 summer, question 2(e):
why $p(y^{(i)}=1)$ equal to $E[p(y^{(i)}=1|x^{(i)})]$ ?
A probability mass is an expectation of the indicator variable for the event. The Law of Total Expectation becomes applicable. Similarly, the conditional expectation is also a conditional probability.
$$\begin{align}p(y^{(i)}=1) &=\mathsf E(\mathbf 1\{y^{(i)}=1\})\\ &=\mathsf E(\mathsf E(\mathbf 1\{y^{(i)}=1\}\mid x^{(i)}))\\ &=\mathsf E(p(y^{(i)}=1\mid x^{(i)}))\end{align}$$
\mathbf 1\{y^{(i)}=1\} produces $\mathbf 1{y^{(i)}=1}$ .
– Graham Kemp
Nov 17 '22 at 13:15