Open Cristianasp opened 6 years ago
Thanks @Cristianasp for reporting this issue.
Although, to reproduce it, y_test
and y_pred
are required.
@scls19fr I've run into the same issue and it seems to be that this multiplication (self.TP + self.FP) * (self.TP + self.FN) * (self.TN + self.FP) * (self.TN + self.FN)
causes an overflow, which returns a negative number. Trying to take the square root of this number then causes the math domain error.
If you punch in my counts to the equation you can easily reproduce it.
FN 8947 FP 22855 TN 53705 TP 36727
I tried those same counts with an alternate formula (see here https://en.wikipedia.org/wiki/Matthews_correlation_coefficient) and didn't receive the error.
Replacing the body of the function with the below fixes the issues.
N = self.TN + self.TP + self.FN + self.FP
S = (self.TP + self.FN) / N
P = (self.TP + self.FP) / N
return ((self.TP/N) - (S*P)) / math.sqrt(P*S*(1-S)*(1-P))
If I can find a bit of time I'll try and submit a pull request.
I just got the same error. Any plans to fix it soon? :|
I also encountered the same error, however @mvanwyk recommendation addressed the issue.
Hello,