jeromeyoon / Tensorflow-siamese

37 stars 14 forks source link

Incorrect accuracy calculation #5

Open tomerv opened 7 years ago

tomerv commented 7 years ago
def compute_accuracy(prediction,labels):
    return labels[prediction.ravel() < 0.5].mean()

This is wrong... it calculates a slice of the prediction array. It selects only the items where the prediction is < 0.5, and calculates the accuracy on those predictions. This gives a false (higher) accuracy calculation. A correct calculation would be

return 1 - np.mean((labels * (prediction > th)) + (1-labels) * (prediction < th))

icarofua commented 7 years ago

A correct accuracy calculation would be return np.mean((labels (prediction > th)) + (1-labels) (prediction < th)). Because TP=(labels (prediction > th)), TN=(1-labels) (prediction < th), in other words, (tp+tn)/total is accuracy.

InstantWindy commented 6 years ago

but What should this ‘th’ value be?