Machine Learning Specialization: Regression and Classification Logistic Regression Decision Boundary

In Course 1 Week 3 why does Andrew state that inside the decision boundary for the elliptical and amorphous decision boundaries the predicted value for logistic regression \hat{y} = 1 when values of x_1 and x_2 are smaller and this means z must be smaller, less than zero and mean the g(z) is less than 0.5 so \hat{y} must be 0 not 1 - correct?

if y_predict > 0.5, then y_hat = 0
if y_predict <= 0.5, then y_hat = 1

that y_hat is class label assigned depending on y predict value

This is a good example of a time when it’s good to focus on the big picture. Remember that in the real world, we could have real target values where the “true” case is inside of an ellipse or amorphous decision boundary, and our job is to find a model that fits that real-world situation.

This could involve using a polynomial equation with positive or negative w and b values. As an example, look at the polynomial from the previous slide, where the decision boundary is x1^2 + x2^2 = 1 and the points inside the circle are 0 and the points outside the circle are 1. If you change the w values to -1 and b to +1, then you would still have the same decision boundary, but the points inside the circle would be 1 and the points outside would be 0. It just depends on what you choose for the w and b values.

I think the thing to focus on here is not so much whether 1 or 0 is inside or outside the shape, but just to recognize that models can get more complex as needed.

2 Likes

y_predict = sigmoid(z), where z = (w*x) + b

x is the features of an example for which you are computing the predicted value.

(Here I am using ‘*’ as a dot product. I can’t write the markdown in a reply very well.)

1 Like

Hi @TMosh,

Thank you for your reply.

Perhaps we could adhere to using the notation and terminology adopted in the course for reasons of clarity and to avoid ambiguity?

Please can you explain which variable you are referring to in the course when you use the word “y_predict”?

Thank you.

Hi Wendy and thank you for taking the time to reply to my previous post.

While I understand the point you have raised about the bigger picture I also think it is important that the course content is correct, not just for me but for other students in the future.

I think we can agree that the decision boundary of the ellipse and the amorphous shape indicates where z = 0 and g(z) = 0.5 - agreed?

If so, then I think we can also agree that regardless of the size and sign of the weight parameters \vec w and bias b smaller values of x_1 and x_2 must cause z to become smaller and negative and g(z) to become less than 0.5 since x_1 and x_2 only appear with positive integer powers greater than or equal to 1 in the mathematical expression for z in the course. This must mean then that the predicted value for the probability that a malignant diagnosis is 0 and not 1 inside the decision boundary, particularly so for the elliptical decision boundary.

Please let me know what you think.

Stephen.

Please explain what variable you are referring to in the course when you use the word “y_predict”

Thank you.

I think @TMosh explained you y predict is sigmoid z.

this is your y predict

Thank you Deepti for your reply but I cannot find a variable called “y_predict” in Prof. Ng’s course curriculum for Logistic Regression.

Do you mean \hat{y}?

Stephen.

I’m not sure what you mean by “sigmoid z”.

Do you mean g(z)?

Stephen.

I thought Prof. Ng assigned the value of 1 to the probability of a malignant tumor when \hat y \geq 0.5

yes.

in the course they didn’t mention.

but y predict same as model predict, you can name any of the two.

using y predict is not mandatory, but for y_hat as the class labels, y predict is used to compare and contrast.

if this confuses you, please ignore my comment and responses :slightly_smiling_face:

Yes, I am confused when notation and terminolgy is introduced in our discussions that is not present in the course curriculum.

It would be clearer to use only the notation and terminology in the course.

I will avoid responding to your queries so you are less confused.

There are many good mentors who surely will help you better.

regards
DP

OK, thanks DP. No problem. I appreciate you taking the time to try and help me.

Here is a link to how you can include mathematical symbols in discussions in this community for the future.

https://rpruim.github.io/s341/S19/from-class/MathinRmd.html

Regards,

Stephen.

i also like to avoid any link outside of the course :crazy_face::joy: to explain mathematical equations of logistics regression.

for me logistics regression is just isn’t mathematical equations but combination of mathematics, science and physics.

Regards
DP

The link doesn’t explain mathematical equations. It tells you how to render mathematical symbols, equations and expressions in Markup for posting in messages here.

y_predict is the predicted logistic value for an example, given some inputs for for x, w, and b.

Yes, in this video we are setting our decision boundary where the sigmoid function g(z) = 0.5, which is where z = 0. And, further, when z > 0, we set y = 1, and when z < 0, we set y = 0.

BUT… that does not mean that smaller values of x_{1} and x_{2} must cause the predicted value inside the decision boundary to be 0. That’s why I used the previous slide as an example. It is an example of a non-linear decision boundary with squared polynomials. In the video, Prof. Ng used w_{1} and w_{2} =1 and b = -1, and you see the result is 0’s inside the circle, and 1’s outside. But, if you use the values I suggested above for w and b (-1 for the w_{1} and w_{2}, +1 for b), then the decision boundary is still the same circle, but now we have 1’s inside the circle and 0’s outside.

Some examples: if x_{1} and x_{2} = 0 (right in the center of the circle), then z = w_{1} * x_{1}^2 + w_{2} * x_{2}^2 + b = -1 * 0 + -1 * 0 + 1 = 1, so z>0, which means y=1 inside the circle.

Similarly, if x_{1} and x_{2} = 2 (outside the circle), then z = -1 * 4 + -1 * 4 + 1 = -4 + -4 + 1 = -7, so, z<0, which means y=0

So, this is an example of how y can be 0 outside the circle and 1 inside the circle if you choose appropriate w and b values.

2 Likes