Skip to content

Commit

Permalink
Replace expanding(axis=1) by T.expanding()
Browse files Browse the repository at this point in the history
  • Loading branch information
romaindeseine committed Dec 11, 2024
1 parent 4309517 commit 3f745ed
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/evidently/metrics/recsys/precision_recall_k.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_precision_and_recall_dict(self, df, max_k):
res["map_include_no_feedback"] = list(
user_df[[f"precision_{k}" for k in range(1, k + 1)]]
.multiply(user_df[[f"rel_{k}" for k in range(1, k + 1)]].values)
.expanding(axis=1)
.T.expanding()
.sum()
.divide(user_df["all"], axis=0)
.fillna(0)
Expand All @@ -65,7 +65,7 @@ def get_precision_and_recall_dict(self, df, max_k):
res["map"] = list(
user_df.loc[user_df["all"] != 0, [f"precision_{k}" for k in range(1, k + 1)]]
.multiply(user_df.loc[user_df["all"] != 0, [f"rel_{k}" for k in range(1, k + 1)]].values)
.expanding(axis=1)
.T.expanding()
.sum()
.divide(user_df.loc[user_df["all"] != 0, "all"], axis=0)
.fillna(0)
Expand All @@ -76,7 +76,7 @@ def get_precision_and_recall_dict(self, df, max_k):
res["mar_include_no_feedback"] = list(
user_df[[f"recall_{k}" for k in range(1, k + 1)]]
.multiply(user_df[[f"rel_{k}" for k in range(1, k + 1)]].values)
.expanding(axis=1)
.T.expanding()
.sum()
.divide(user_df["all"], axis=0)
.fillna(0)
Expand All @@ -85,7 +85,7 @@ def get_precision_and_recall_dict(self, df, max_k):
res["mar"] = list(
user_df.loc[user_df["all"] != 0, [f"recall_{k}" for k in range(1, k + 1)]]
.multiply(user_df.loc[user_df["all"] != 0, [f"rel_{k}" for k in range(1, k + 1)]].values)
.expanding(axis=1)
.T.expanding()
.sum()
.divide(user_df.loc[user_df["all"] != 0, "all"], axis=0)
.fillna(0)
Expand Down

0 comments on commit 3f745ed

Please sign in to comment.