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

 A: You were given $P(y_i = 1|x_i) = 1-P(y_i = 0|x_i) = g(w^Tx_i)$.
That implies the following two equations (among others):
\begin{align}
P(y_i = 1|x_i) &= g(w^Tx_i), \tag 1\\
P(y_i = 0|x_i) &= 1 - g(w^Tx_i). \tag 2
\end{align}
So it's not simply $P(y_i|x_i) = g(w^Tx_i)$.
The right-hand side depends on the value of $y_i$.
Suppose $y_i = 1$. Then your "hint" says that
\begin{align}
P(y_i|x_i) & = (g(w^Tx_i))^{y_i}(1-g(w^Tx_i))^{1-y_i} \\
 & = (g(w^Tx_i))^1 (1-g(w^Tx_i))^{1-1} && \text{because $y_i = 1$} \\
 & = (g(w^Tx_i))^1(1-g(w^Tx_i))^0 \\
 & = g(w^Tx_i), 
\end{align}
which is the same as equation $(1)$.
Alternatively, suppose $y_i = 0$. Then your "hint" says that
\begin{align}
P(y_i|x_i) & = (g(w^Tx_i))^{y_i}(1-g(w^Tx_i))^{1-y_i} \\
 & = (g(w^Tx_i))^0 (1-g(w^Tx_i))^{1-0} && \text{because $y_i = 0$} \\
 & = (g(w^Tx_i))^0(1-g(w^Tx_i))^1 \\
 & = 1 - g(w^Tx_i),
\end{align}
which is the same as equation $(2)$.
So the hint does not contradict what you received before; it just
expresses it in a different form.
A: 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.
