Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Bug: Precision and Recall metrics return the exact same value

Closed Beginner friendly
#10 1 comment 0 reactions 1 assignee View on GitHub

@sohanjadyal is already working on this.

Since Oct 7, 2026.

  • #13 by @sohanjadyal — open

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
88/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Read mess_mood/metrics.py and the test_metrics function in tests/test_mess_mood.py; the issue identifies the incorrect precision formula and gives a failing example. Run the metrics test first, then verify precision uses true positives and false positives while recall still passes. Done when the test expects precision 1.0 and the metrics tests pass.

Written by the indexing model from the issue text.

Description

What I did:
I checked the implementation of the precision function inside mess_mood/metrics.py to see how model evaluation metrics were being calculated. To prove my findings, I updated the test_metrics function in tests/test_mess_mood.py to actually test the precision mathematically:

Click to view the test code
def test_metrics():
    y_true = ["pos", "pos", "neg", "neg"]
    y_pred = ["pos", "neg", "neg", "neg"]
    assert accuracy(y_true, y_pred) == 0.75
    assert recall(y_true, y_pred, "pos") == 0.5
    
    # I added this line. Mathematically, True Positives = 1, False Positives = 0.
    # Therefore Precision = 1 / (1 + 0) = 1.0
    assert precision(y_true, y_pred, "pos") == 1.0
    
    assert f1(1.0, 0.5) == 2 / 3
    assert confusion_matrix(y_true, y_pred, ["neg", "pos"]) == {"neg": {"neg": 2, "pos": 0}, "pos": {"neg": 1, "pos": 1}}

What I expected:
The README states that precision is "of the reviews the model gave that label, the share that really had it." Mathematically, this means the formula should be True Positives divided by True Positives plus False Positives (tp / (tp + fp)). The new test case should pass because the precision is 1.0.

What happened instead:
The precision function returns tp / (tp + fn). This is the exact formula for recall (True Positives plus False Negatives), meaning the precision metric currently duplicates the recall metric entirely.

Running the test confirms this; it fails because the precision function returns 0.5 instead of 1.0:

Proof (Terminal Output / Screenshot):

Image
Dominant language
Python
Stars
0
Forks
3
Avg merge
10h 15m
Merged PRs (30d)
7

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from techcsispit/mess-mood

All issues in techcsispit/mess-mood

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.