napkinxc.measures.ndcg_at_k¶
- napkinxc.measures.ndcg_at_k(Y_true, Y_pred, k=5, zero_division=0)[source]¶
Calculate normalized Discounted Cumulative Gain (nDCG) at 1-k places.
- Parameters:
Y_true (ndarray, csr_matrix, list[list|set[int|str]]) – Ground truth provided as a matrix with non-zero values for true labels or a list of lists or sets of true labels.
Y_pred (ndarray, csr_matrix, list[list[int|str]], list[list[tuple[int|str, float]]) – Predicted labels provided as a matrix with scores or list of rankings as a list of labels or tuples of labels with scores (label, score). In the case of the matrix, the ranking will be calculated by sorting scores in descending order.
k (int, optional) – Calculate at places from 1 to k, defaults to 5
zero_division (float, optional) – Value to add when there is a zero division, typically set to 0, defaults to 0
- Returns:
Values of nDCG at 1-k places.
- Return type:
ndarray