3

I have an array of probabilities:

proba =  :[[0.254 0.556 0.025] [0.898 0567 .112]]

want max value from each as [[0.556] [0.898]]

How i can do it? Tried 2 methods:

 1. max(sublist) for sublist in proba 
 2. proba = map(max,proba)

and getting error "TypeError: 'numpy.float32' object is not iterable"

Any suggestion?

3
  • What's with the : before your array? Commented Dec 8, 2017 at 16:06
  • The code you provided is not even valid Python Commented Dec 8, 2017 at 16:09
  • Please check the syntax before posting Commented Dec 8, 2017 at 16:18

1 Answer 1

1

I can notice some problems in your code, first of all, your data list is not in the correct format, commas are missing and there is an extra ':' at the right of the equal sign

proba = [[0.254, 0.556, 0.025], [0.898, 0.567, .112]] 

And then you can get the answer like this :

max_ = [max(i) for i in proba]
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.