[Math] Updating weights in logistic regression using gradient descent

error functiongradient descentlogistic regressionmachine learningoptimization

The loss function for logistic regression is $\sigma(z)$=$\frac{1}{1+e^{-z}}$ and $z=\theta^T.x_i$ but in order to make our loss function convex we consider this alternative formula:
$$-\frac{1}{n}\sum_{i=1}^n[y_i.log(h_\theta x_i) + (1-y_i)(1-h_\theta x_i)]$$

If we take derivative of this loss function w.r.t $\theta_i$ then we'd get something like:
$$-\frac{1}{n}\sum_{i=1}^n (h_\theta(x) – y_i)*x_j$$

Now the gradient update step will be,
$$\theta_i := \theta_i -\alpha.-\frac{1}{n}\sum_{i=1}^n (h_\theta(x) – y_i)*x_j$$

My doubt is what is $h_\theta(x)$ here? Is it sigmoid function i.e $\frac{1}{1+e^{-z}}$? Another doubt is what is $x_j$ term here refer to? Is it our input datapoint?

Is my understanding clear regarding the loss function above. If any mistakes please do correct me? I am following andrew-ng ML course.

Best Answer

My doubt is what is $hθ(x)$ here? Is it sigmoid function i.e $\frac{1}{1+e^{-z}}$?

$h_{\theta}(x)$ is your hypothesis function. Which is given as

$$ h_{\theta}(x) = \frac{1}{1+e^{-\theta^{t}x}} $$

So if you sigmoid function $\sigma(z)$ is given as

$$ \sigma(z) =\frac{1}{1+e^{-z}} $$

Another doubt is what is $xj$ term here refer to? Is it our input datapoint?

$x_{j}$ is one of the samples.

Related Question