Skip to content

Commit

Permalink
add another test for mrr
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickjohncyh committed Jul 27, 2023
1 parent ffd937d commit 6b3c5c6
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_reclist.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ def test_mrr():
[[10, 12, 14, None, None, None],
[22, 8, 64, 13, 1, 0]]
)
df_f = pd.DataFrame(
[[10, 12, 14, None, None, None],
[22, 1, 64, 13, 1, 0]]
)

df_g = pd.DataFrame(
[[10, 12, 14, None, None, None],
[22, 17, 64, 13, 1, 0]]
)
# df_f = pd.DataFrame(
# [[2, 3],
# [0, 1]]
Expand All @@ -95,4 +104,13 @@ def test_mrr():
assert mrr_at_k(df_e, df_d, 2) == 1/4
assert mrr_at_k(df_e, df_d, 3) == pytest.approx(5/12)
assert mrr_at_k(df_e, df_d, 6) == pytest.approx(5/12)

# k larger than pred size
assert mrr_at_k(df_e, df_d, 20) == pytest.approx(5/12)

# repeated prediction that is a hit
assert mrr_at_k(df_f, df_d, 6) == pytest.approx(5/12)

assert mrr_at_k(df_g, df_d, 6) == pytest.approx(4/15)


0 comments on commit 6b3c5c6

Please sign in to comment.