# C1_W3_Lab02_Sigmoid_function - how the graph given the data?

I’ve tried to search this forum but don’t see an answer for what I’m going to ask - which seems to indicate I’m missing something

at the bottom of this lab we’re given this
x_train = np.array([0., 1, 2, 3, 4, 5])
y_train = np.array([0, 0, 0, 1, 1, 1])
w_in = np.zeros((1))
b_in = 0

we’re then asked to Click on ‘Run Logistic Regression’ to find the best logistic regression model for the given training data
*plt.close(‘all’) *

with w_in and b zeroed then z = 0 for each example x, then g(z) = g(0.5) = 0 for each example x.
From those initial values of x_train, w_in, b_in I don’t get the results than map to the graph.

Not sure where I’m going wrong and any guidance is welcome. Thanks in advance!

No, that should be z = 0, and g(0) = 0.5

What graph do you get? Please post a screen capture image.

my typo, yes z=o for all examples of x_train which means g(z) is 0.5 for all examples of x_train.

but my confusion continues since the sigmoid curve isn’t 0.5 for all examples of x_train.

well g(z) = 0.5 for all x_train using the w_in and b_in

This is the graph from the lab which looks fine and I’m not querying that. I just can’t get my head around how we go from:
x_train = np.array([0., 1, 2, 3, 4, 5])
and z = 0 for all examples
and g(z) = 0.5 for all examples
to that graph

I suspect you clicked the “Run Logistic Regression” button, and learned the correct weights.

aha I see now. The chart before clicking the button does indeed have the line g(z) = 0.5
I mistakenly thought that any input into the sigmoid function would produce a similar S curve but it’s clear that’s not the case.

Thanks for the responsiveness especially over Christmas - it is very much appreciated! I hope you have a great rest of the holidays.

1 Like