Fix accuracy/f1 scoring the mismatch rate instead of the match rate by shaurya416 · Pull Request #15 · codefuse-ai/codefuse-evaluation · GitHub
Skip to content

Fix accuracy/f1 scoring the mismatch rate instead of the match rate - #15

Open
shaurya416 wants to merge 1 commit into
codefuse-ai:masterfrom
shaurya416:fix-accuracy-f1-polarity
Open

shaurya416 wants to merge 1 commit into
codefuse-ai:masterfrom
shaurya416:fix-accuracy-f1-polarity

Conversation

@shaurya416

Copy link
Copy Markdown

Fixes #14.

check_currentmetric builds the inputs for the accuracy and f1 metrics as

predictions = [0 if prediction == reference else 1 for prediction, reference in zip(predictions, references)]
references = [1] * len(references)

and passes them to metrics/accuracy and metrics/f1. accuracy_score(references, predictions) then counts the rows where the prediction is 1, which are the rows where the generation did not match. A correct generation scores 0 and a wrong or empty one scores 1.

This swaps the two values, so a match is 1. The change is the same one line in codefuseEval/execution.py and in codefuseEval_202503/execution.py. The f1 value keeps its existing formula (F1 of the positive class with all-1 references); only its polarity changes.

Verification

The repo has no Python tests, so I did not add one. I extracted check_currentmetric verbatim from each file with ast and ran it against the repo's own metrics/accuracy/accuracy.py and metrics/f1/f1.py with real scikit-learn 1.4.2. evaluate and datasets are small stand-ins (only the Metric base class and a docstring decorator). Each row is a set of 10 generations checked against the reference "x":

generations accuracy before accuracy after f1 before f1 after
10 of 10 correct 0.0 1.0 0.0 1.0
5 of 10 correct 0.5 0.5 0.6667 0.6667
0 of 10 correct 1.0 0.0 1.0 0.0
10 empty generations 1.0 0.0 1.0 0.0

codefuseEval_202503 has no metrics/ folder in this repository, so I ran its check_currentmetric (byte-identical to the other copy) against the metrics/ folder from codefuseEval; the results are the same as above.

check_currentmetric mapped a correct generation to 0 and a wrong one to 1
and then compared against all-1 references, so accuracy and f1 measured the
fraction of mismatches. Swap the two values in both execution.py copies.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

check_currentmetric() inverts accuracy/f1: exact-match generations score 0.0, all-wrong/empty generations score 1.0

1 participant