Sigmoid is clearly not a straight line, so there must be something wrong with your methodology. For starters, note that your first four X values will all give the same value of z when w = [1,1], right?

Kamesh, Paul’s check is the first thing we should do. The first three X values give us the same z, but how many different z do we expect to have? With such number of different points, can we see a curve easily?

Here is the output of z and sigmoid(z) for my example data, I see the first three values of Z and its corresponding g(z) is same inline with your comment earlier.

Maybe test your plotting separately from the sigmoid function by just plotting these points. They should form a parabola.
-3,9
-2,4
-1,1
0,0
1,1
2,4
3,9

I think you are missing the point about why that is a problem. Think about it: there are really only 3 distinct points there. So you are drawing the graph based on just 3 points. How is that possibly going to show the full curvature of the sigmoid function? So, yes, you need to modify your input data to provide more variety. What is the point (pun intended) of including duplicate points?

Here is something I tried now with a bigger data set,

import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
def sigmoid(z):
"""
Compute the sigmoid of z
Args:
z (ndarray) : A scalar, numpy array of any size
Returns:
g(ndarray): sigmoid(z), with the same shape as z
"""
g_z = 1/(1+ np.exp(-z))
return g_z
def load_data(filename):
data = np.loadtxt(filename, delimiter=',')
X = data[:,:2]
y = data[:,2]
return X, y
X,_ = load_data('./data/ex2data2.txt')
w = np.array([1,1])
b = -3
z = np.dot(X,w)+ b
# disregard duplicates
z = np.unique(z)
g_z = sigmoid(z)
# just printing some samples
print(f"z:{z[:5]}")
print(f"sigmoid(z):{g_z[:20]}")
plt.plot(z,g_z,c="b")
plt.title("Sigmoid Function")
plt.xlabel("z")
plt.ylabel("$g(z)$")
plt.show()

That probably is correct for that domain of the function, but you really need to include something like the range I suggested from -5 to 5 to see the full shape of sigmoid. Note that I mean that as the range for z, not for x.

Note that your choice of b = -3 and w = [1,1] is going to skew the results in the negative direction.

I would start by just graphing sigmoid without the z = x \cdot w + b first just to see the shape of sigmoid. Then take the next step of figuring out what range of x values you need to cover the domain [-5, 5] for the inputs to sigmoid.