I am trying to use numpy in Python in solving my project.
I have a random binary array
rndm = [1, 0, 1, 1]
and a resource_arr = [[2, 3], 4, 2, [1, 2]]
. What I am trying to do is to multiply the array element wise, then get their sum. As an expected output for the sample above,
output = 5 0 2 3
. I find hard to solve such problem because of the nested array/list
.
So far my code looks like this:
def fitness_score():
output = numpy.add(rndm * resource_arr)
return output
fitness_score()
I keep getting
ValueError: invalid number of arguments.
For which I think is because of the addition that I am trying to do. Any help would be appreciated. Thank you!