TypeError: int() argument must be a string, a bytes-like object or a number, not 'list'

f(Y,Yscore)=−1∗1nΣforeachY,Yscorepair(Ylog10(Yscore)+(1−Y)log10(1−Yscore))

logLoss = sum([int(A[i])*log(float(A[j]))+ (1-int(A[i]))*log(1-float(A[j])) for i in range(len(A)) for j in range(len(A))])
    logLoss = logLoss * -1/(len(A))

I am getting logLoss using the formula given above f(Y,Yscore). But when I run the above statement, I get the error :
TypeError: int() argument must be a string, a bytes-like object or a number, not ‘list’

is there a way to fix it.

Can you explain to me how? Cause the formula you provided features no division readily apparent. Sigma is not an average.

Also log is not the same as log 10. The default base for the math.log function is e, not 10.

What is the structure of A? is it a list of numbers? Is it a multidimensional array?

Ex: A = [[1, 0.4], [0, 0.5], [0, 0.9], [0, 0.3], [0, 0.6], [1, 0.1], [1, 0.9], [1, 0.8]]
output: 0.44982

Right.
So you’ve told python

int(A[i])
Lets assume we’re on our first iteration, so i = 0 j = 0.
A[0] is [1,0.4]
Python says “what is the int value of a list of 2 items? I don’t know. Go away.”

Yes, Now I changed my code to use log10 and as below:

logLoss = sum([int(A[i][0])*log10(float(A[j][1]))+ (1-int(A[i][0]))*log10(1-float(A[j][1])) for i in range(len(A)) for j in range(len(A))])
logLoss = logLoss * -1/(len(A))

I am getting the output = 3.2262853510984653
but expected output = : 0.44982

I have confusion in writing the mathematical formula in python. If calculate it with the calculator I get the output=0.44982, but with the python code, I am getting wrong output.
Is there anything I need to fix it.
f(Y,Yscore)=−1∗(1/n)*ΣforeachY,Yscorepair(Ylog10(Yscore)+(1−Y)log10(1−Yscore))

. . .

Noone knows what you mean by this:

What is Yscorepair? That’s not a mathematical function.

We can say take Y=a and Yscorepair=b
f(Y,Yscore)=−1∗(1/n)*ΣforeachY,Yscorepair(Ylog10(Yscore)+(1−Y)log10(1−Yscore)) can be written as
f(a,b)= −1∗(1/n)*Σforeach a,b(alog10(b)+(1−a)log10(1−b))

okay, i think i see what you’re trying to say. Let me see if i can flesh it out a bit to make it more readable:

Except… are you trying to do this for every combination of indexes?
IE, you want to do this for (1,0.4),(1,0.5),(1,0.9) … (0,0.4),(0,0.5) …?

Let me phrase that better.

If your array A was as follows: [[a,1],[b,2],[c,3]],
Are you expecting it to run your function for
F(a,1), F(a,2), F,(a,3), F(b,1), F(b,2), F,(b,3), F(c,1), F(c,2), F,(c,3)
or just
F(a,1), F(b,2), F,(c,3)?

Yes, for a given n number of combinations

We have a list of lists, each sublist will be of length 2 i.e. [[x,y],[p,q],[l,m]…[r,s]] consider its like a martrix of n rows and two columns
a. the first column a will contain interger values
b. the second column b will be having float values

This is the formula I am working on

Yup. I got that.
For the first value of the first column, X.
Would you run the function against ALL values of the second column? or only the first value of the second column?

No, For the first value of the first column, X, we would run the function only on the first value of the second column.
Its like Xi, Yi, where i=1 to N; if its X1, then we will take Y1
if its X2, then we will take Y2 , so on. Thats what I understand from the formula.

Okay, so that’s NOT what your code is saying.
for i in range(len(A)) for j in range(len(A))])
You’re running a loop inside a loop.

sum([int(A[i][0])*log10(float(A[j][1]))
this should just use i everywhere.
sum([int(A[i][0])*log10(float(A[i][1]))
etc.

Incidentally, unless i’ve done something wrong, my math tells me the answer to your example should be 0.424309935.

Yes you are correct. I really appreciate your help.
Thank you