Error in calculating the accuracy


Good morning dear all,

I got this error while executing the get_accuracy function we used in week 2 assignment,
Can you please help me to solve it?

Hi @Youstina.Ghoris ,
Could you please check if the data type of both y and pred is a numpy array and not a list or some other type. You can do so by following below code:
type(y),type(pred)

1 Like

You have used float in the array and passing that array as an index to another array. The float needs to be converted to integer

1 Like

hello @Smriti93,
many thanks for your reply ,dear.
I already checked it but they are np.arrays , still getting the same error :frowning_face:

Hello @sbansal793,
many thanks for your reply.

can you elaborate more please, what does it mean to pass an array as index to another array?

A=[2,47,28,28,49,18]
B=A([0,2,3])
print(B)

[2,28,28]

All arrays are numpy arrays. The value of 0,2,3 are integers not float values. That is where you are going wrong. For future reference, copy the error and paste it on google. You will definitely find the solution of your errors on forums like stackoverflow, stackexchange , etc