Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Computing ranking metrics on first positive label #230

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ def compute_aux_metrics_on_query_group(query_group: pd.DataFrame,
compute_aux_metrics(
aux_label_values=query_group[aux_label],
ranks=query_group[old_rank_col],
click_rank=query_group[query_group[label_col] == 1][old_rank_col].values[0]
click_rank=query_group[query_group[label_col] == 1][old_rank_col].min()
if (query_group[label_col] == 1).sum() != 0
else float("inf"),
prefix="old_",
Expand All @@ -277,7 +277,7 @@ def compute_aux_metrics_on_query_group(query_group: pd.DataFrame,
compute_aux_metrics(
aux_label_values=query_group[aux_label],
ranks=query_group[new_rank_col],
click_rank=query_group[query_group[label_col] == 1][new_rank_col].values[0]
click_rank=query_group[query_group[label_col] == 1][new_rank_col].min()
if (query_group[label_col] == 1).sum() != 0
else float("inf"),
prefix="new_",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def get_grouped_stats(
df_clicked = df[df[label_col] == 1.0]
df = df[df[query_key_col].isin(df_clicked[query_key_col])]

# Pick most relevant record for each query to compute ranking metrics
df_clicked = df_clicked.groupby(query_key_col).apply(min)

# Compute metrics on aux labels
df_aux_metrics = pd.DataFrame()
if aux_label:
Expand Down
1 change: 1 addition & 0 deletions python/ml4ir/base/model/scoring/prediction_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def _predict_score(features, label):
if is_compiled:
scores = infer(features)[output_name]
else:
import pdb; pdb.set_trace()
scores = infer(**features)[output_name]

# Set scores of padded records to 0
Expand Down