The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

https://github.com/abdmunir81/mlpR/blob/main/prework





Hi Quantra…



Need some help with the codes above that return with an error at  "handle_data"



The error is   """

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

          """

Does the array is wrong somehow?

Thank you,

this means most probably you are using some sort of boolean test on this array or on an expression using this array.  E.g.



if x == 0:

    # do something here

    pass



If x is an array, the results of x==0 will be an array of True or False, But the 'if' test cannot handle an array of boolean values, it expects a single value, True or False. That is what the error message suggests, using 'any' or 'all' to reduce the boolean array to a single boolean value.



In your case, most probably the issue is the 'y_pred' variable returned from the 'ann' function. Check for its type, it is perhaps an array with a single element. In that case you want to return that element from the function, than the array itself. 

Thank you Sir…





will check on it…