From 3f745edbe3c6ecf1b7d2a4543b16ca5e5875f3a9 Mon Sep 17 00:00:00 2001 From: Romain Deseine Date: Wed, 11 Dec 2024 10:47:59 +0100 Subject: [PATCH] Replace expanding(axis=1) by T.expanding() --- src/evidently/metrics/recsys/precision_recall_k.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/evidently/metrics/recsys/precision_recall_k.py b/src/evidently/metrics/recsys/precision_recall_k.py index e40802ee4d..fdc3c17d32 100644 --- a/src/evidently/metrics/recsys/precision_recall_k.py +++ b/src/evidently/metrics/recsys/precision_recall_k.py @@ -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) @@ -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) @@ -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) @@ -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)