-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
Description:
I discovered that the Precision and Recall have their logic reversed, the Precision metric is actually calculating Recall, and the Recall metric is calculating Precision.
The Issue:
In the Precision implementation, when counting false positives in binary classification:
if y_pred.get(i) == y_true.get(i) {
if classes == 2 {
if *y_true.get(i) == T::one() {
tp += 1;
}
} else {
tp += 1;
}
} else if classes == 2 {
if *y_true.get(i) == T::one() {
fp += 1;
}
}
This checks if y_true == 1 when predictions don't match. However, this is counting false negatives (when true=1 but pred=0), not false positives. False positives should be when we predict 1 but true label is 0.
Similarly, in the Recall implementation, when counting false negatives:
if y_pred.get(i) == y_true.get(i) {
if classes == 2 {
if *y_true.get(i) == T::one() {
tp += 1;
}
} else {
tp += 1;
}
} else if classes == 2 {
if *y_true.get(i) != T::one() {
fne += 1;
}
}
This checks if y_true == 0 when predictions don't match, which actually counts false positives (when true=0 but pred=1), not false negatives.
Impact:
- Precision scores are actually Recall scores
- Recall scores are actually Precision scores
- F-beta scores with beta ≠ 1 are incorrect
Metadata
Metadata
Assignees
Labels
No labels