Reputation: 1
so I am working on finding the sigmoid equation for logistic regression for matrices. I have two matrices, z and g, and would like to replace the values in g with the sigmoid values. I have the following code, but cannot figure out how to replace the elements in g with its respective sigmoid value. Any help would be appreciated!
I have the following:
z = np.array([[1, 4, 5, 12], [-5, 8, 9, 10], [-6, 7, 11, 19]])
g = np.zeros(z.shape)
for row in z:
for i in row:
sigmoid = 1/(1+np.exp(-i))
Upvotes: 0
Views: 41
Reputation: 2493
You can do it without a loop:
z = np.array([[1, 4, 5, 12], [-5, 8, 9, 10], [-6, 7, 11, 19]])
g = 1/(1+np.exp(-z))
Upvotes: 1