I have a project that goes like this:
data = [[0, 1], [1, 1], [1, 0], [0, 1]]
res = [4, 2]
The objective is to multiply res with each element in data and get the sum. For example:
sum_prod = [[4*(0) + 2*(1)], [4*(1) + 2*(1)], [4*(1) + 2*(0)], [4*(0) + 2*(1)]]
sum_prod = [2, 6, 4, 2] # expected output
The code I have looks like this:
def fitness_score(g, u):
a = g
b = u
arr = a @ ab
fitness_value = arr.T.tolist()
return fitness_value
And here is how to call the function fitness_score
fitness_score (data, res)
This snippet of code that I have works if the data to be called are numpy arrays
The problem is, there are parts in my code which doesn’t accept numpy arrays.
Is there anyway to change the code I have that would readily take lists rather than numpy arrays? So that I could use it all throughout my code?
Any help would be appreciated! Thanks!