0

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))
2
  • Question has in fact nothing to do with machine-learning, kindly do not spam irrelevant tags (removed). Commented Aug 16, 2020 at 18:41
  • check this out <stackoverflow.com/questions/19666626/…>? Commented Aug 16, 2020 at 18:48

1 Answer 1

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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.