Skip to content

Instantly share code, notes, and snippets.

View sa-'s full-sized avatar

Samay Kapadia sa-

View GitHub Profile
@sa-
sa- / pandas_ndcg.py
Created December 16, 2019 16:01
Compute ndcg@k from your dataset
# Compute ndcg @ k
def ndcg_at_k(predictions_df, k):
"""
This pandas dataframe should contain the columns "customer_id",
"estimate", and "label".
Where `estimate` is a recommendation score
that we can sort by descending order.