0

In cs229, the problem set1 of 2019 summer, question 2(e):

enter image description here

why $p(y^{(i)}=1)$ equal to $E[p(y^{(i)}=1|x^{(i)})]$ ?

doraemon
  • 123

1 Answers1

2

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}$$

Graham Kemp
  • 129,094
  • Thank you! And I want to ask for one more question: is $h(x^{(i)})$ and ${1}(y^{(i)}=1}$ independent? – doraemon Nov 17 '22 at 07:50
  • I am sorry that I don't know how to type the indicator function of $y^{(i)}$ properly... – doraemon Nov 17 '22 at 07:54
  • 1
    @gczday (1) You haven't provided any information on the random variables. This holds whether they are or are not. Still, if they are independent you don't need conditioning. (2) \mathbf 1\{y^{(i)}=1\} produces $\mathbf 1{y^{(i)}=1}$ . – Graham Kemp Nov 17 '22 at 13:15