Why logistic cost function doesn't get subtracted from ground truth

The cost discussed in the course is

In the above formula, subtracting the predicted value from the ground truth is missing

But suddenly, when we implemented Gradient Descent, from where did the y(i) come

In gradient descent, we’re subtracting the predicted value from the ground truth. How we’re subtracting from ground truth which was not available in cost function

But this wasn’t the case with Linear Regression.

Subtracting from ground truth was there in both Cost functions and thus was available in GD as well

1)The logistic cost does not use subtraction of the y value. It is a different cost function than was used for linear regression. (Updated) Logistic regression uses the product of ‘y’ and the log() of the sigmoid of the prediction.

2)However, the equation for the gradients is quite similar. It’s due to how the partial derivatives are computed.

Hello @Naren_babu_R

I just want to add that having the “subtraction” term in the cost function isn’t a necessary condition to have the “subtraction” term in the gradient of the cost function. We need to be clear about this. I would also like to draw your attention to this post which will tell us that the “subtraction” term shows up after taking the derivative.

Raymond

@rmwkwok @TMosh Still I’m struck.

Linear Regression:
imagehere
where
Screenshot from 2023-02-26 17-15-47
is partial differentiation of cost function(J) w.r.t to w
As a result, I get
image
where J is
image

Here I’m convinced with theimage term. Straight forward logic.

Logistic Regression:
same GD as LR
image
where
image

Doubt:
From where I’m gettingimage term in GD of Logistic Regression.
Can you please explain? Totally confused :woozy_face:.

if image is partial differentiation of cost function(J) w.r.t to w,
From where we’re getting the image

You have shown the J for linear regression. Why don’t you also show the J for logistic regression? There is y^{(i)} in that J. Please show that J. :wink:

If you start from the equation for the logistic cost, then work through all of the steps in the calculus of the partial derivative of the logistic cost, you’ll then understand sentence 2) in my previous reply.