# Log loss when classes are -1 and +1 [duplicate]

We can calculate the log loss for a classification problem with two classes as follows:

where y is the label of the actual class and p the probability of the class being positive (e.g. P(y=1)).

However, this assumes that y has the classes 0 and 1. What can I do when my class labels are actually -1 and +1? How do you calculate the log loss in that case?

• – Tim May 29 '18 at 8:54
• recode your classes? convert -1 to 0 – ReneBt May 29 '18 at 8:56
• Compose $\frac{z+1}{2} \mapsto y$ with your function $L: y \mapsto \ell$. – Neil G May 29 '18 at 9:01
• Think of an outcome $y=a, b$ and write the log likelihood function (don't call this log loss) by replacing $y$ with $y=b$ and $1-y$ with $y=a$ and you'll see the general issue. This is only a labeling issue and no math is required. – Frank Harrell May 29 '18 at 12:04
• @FrankHarrell No I agree, there is clearly an issue when you apply the classes {-1,+1}. But since the interval between the two is not important, it might as well be A or B (in my case, stock price Up or stock price Down), then I guess I can just replace -1 with 0. – JohnAndrews May 29 '18 at 16:40