ndcg: Normalized Discounted Cumulative Gain (NDCG)

View source: R/metrics.R

ndcgR Documentation

Normalized Discounted Cumulative Gain (NDCG)

Description

Computes the Normalized Discounted Cumulative Gain on a proportion of top observations.

Usage

ndcg(observed, predicted, proportion = 1)

Arguments

observed

(numeric) The observed values. It has to have the same length as predicted.

predicted

(numeric) The observed values. It has to have the same length as observed.

proportion

(numeric(1)) The proportion of top observations used to compute the metric. 1 by default.

Details

Normalized Discounted Cumulative Gain is computed as:

dcg / idcg

where y_i is the observed value of element i, haty_i is the predicted value of element i and k is the number of top observations specified in the proportion parameter.

Value

A single numeric value with the Normalized Discounted Cumulative Gain.

See Also

Other rank_metrics: best_lines_match()

Examples

## Not run: 
set.seed(1)
x <- rnorm(100)
y <- rnorm(100)
ndcg(x, x)
ndcg(x, x - 1)
ndcg(x, x + 10)
ndcg(x, y)

## End(Not run)


brandon-mosqueda/SKM documentation built on Feb. 8, 2025, 5:24 p.m.