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))
desertnaut
60.8k32 gold badges155 silver badges183 bronze badges
1 Answer 1
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))
answered Aug 16, 2020 at 18:45
Gil Pinsky
2,4931 gold badge14 silver badges17 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
lang-py
machine-learning, kindly do not spam irrelevant tags (removed).