sklearn.metrics.ndcg_score

sklearn.metrics.ndcg_score(y_true, y_score, k=5)[source]

Normalized discounted cumulative gain (NDCG) at rank K.

Normalized Discounted Cumulative Gain (NDCG) measures the performance of a recommendation system based on the graded relevance of the recommended entities. It varies from 0.0 to 1.0, with 1.0 representing the ideal ranking of the entities.

Parameters:

y_true : array, shape = [n_samples]

Ground truth (true labels represended as integers).

y_score : array, shape = [n_samples, n_classes]

Predicted probabilities.

k : int

Rank.

Returns:

score : float

References

[R231]Kaggle entry for the Normalized Discounted Cumulative Gain