Skip to content

LinkPredNDCG

LinkPredNDCG(k: int, weighted: bool = False)

Bases: LinkPredMetric

NDCG @ \(k\) (Normalized Discounted Cumulative Gain), which gives more weight to relevant items ranked higher.

Parameters:

Name Type Description Default
k int

The number of top-\(k\) predictions to evaluate against.

required
weighted bool

Whether the ground-truth items have graded relevances given by edge_label_weight. Default: False

False
Source code in mlx_graphs/metrics/link_pred.py
def __init__(self, k: int, weighted: bool = False):
    super().__init__(k)
    self.weighted = weighted
    self.discount = np.log2(np.arange(2, k + 2, dtype=np.float64))
    self.idcg = None if weighted else _exclusive_cumsum(1.0 / self.discount)

from mlx_graphs.metrics import LinkPredNDCG · mlx_graphs/metrics/link_pred.py