Skip to content

Instantly share code, notes, and snippets.

@rashomonset
rashomonset / rank_metrics.py
Last active September 17, 2019 08:20 — forked from bwhite/rank_metrics.py
Ranking Metrics
import numpy as np
def dcg_at_k(r, k, method=0):
"""Score is discounted cumulative gain (dcg)
Relevance is positive real values. Can use binary
as the previous methods.
Args:
r: Relevance scores (list or numpy) in rank order