lisa-lab/pylearn2

F-score expresion is wrong

Opened this issue · 1 comments

The F-score expresion in compute_f1() in expr/nnet.py is given by:

f1 = (2. * precision * recall /
T.maximum(1, precision + recall))

As far as I understand, T.maximum() is used to avoid the denominator from being zero. While this protection is fine in compute_recall() and compute_precision() in the same file, in compute_f1() this is wrong because precision+recall can legitimally be lower than 1, and in those cases, the reported f-score would be wrong (lower than it should be).

My suggestion is to implement this formula instead:

f1 = 2_hits / maximum(1,2_hits + false_alarms + misses)

I think using
f1= 2_hits/max(1,2_hits+false_alarms+misses)
would be a great idea