Probability - Can't understand hint professor gave You don't really need any expert knowledge in Machine Learning or linear regression for this question, just probability.
Our model is this: We have our input matrix $X \in \mathbb R^{n \times d}$ and our output vector $y \in \mathbb R^n$ which is binary. $y_i$ is either $0$ or $1$.
We have $P(y_i = 1|x_i) = 1-P(y_i = 0|x_i) = g(w^Tx_i)$ where $g(z) = \frac{1}{1+e^{-z}}$ is the sigmoid function, $x_i$ denotes the $i$'th row of the matrix $X$, and $w \in \mathbb R^d$ maximizes our likelihood function defined $l(w) = \frac{1}{n} \sum_{i=1}^{n}\log(P(y_i|x_i))$
I was asked to prove that $\frac{\partial l}{\partial w} = \frac{1}{n} \sum_{i=1}^{n}x_i(y_i - g(w^Tx_i))$
We had a hint: Observe that $P(y_i|x_i) = g(w^Tx_i)^{y_i}(1-g(w^Tx_i))^{1-y_i}$
I don't understand how can the hint be true. It was defined at the beginning that $P(y_i|x_i) = g(w^Tx_i)$. This seems different.
Edit: Here is the specific text the teacher gave


It's just a way of writing two identities in one.
If $y_1 = 0$ you get what you had before, and similarly if $y_1= 1:$ there's always one of the two terms canceling. Since $0$ and $1$ are the only possible valuse you can get, the equality holds.
