Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

mapk

Mean Average Precision at k


Description

mapk computes the mean average precision at k for a set of predictions, in the context of information retrieval problems.

Usage

mapk(k, actual, predicted)

Arguments

k

The number of elements of predicted to consider in the calculation.

actual

A list of vectors, where each vector represents a ground truth vector of relevant documents. In each vector, the elements can be numeric or character values, and the order of the elements does not matter.

predicted

A list of vectors, where each vector represents the predicted vector of retrieved documents for the corresponding element of actual. In each vector, the order of the elements does matter, with the elements believed most likely to be relevant at the beginning.

Details

mapk evaluates apk for each pair of elements from actual and predicted.

See Also

Examples

actual <- list(c('a', 'b'), c('a'), c('x', 'y', 'b'))
predicted <- list(c('a', 'c', 'd'), c('x', 'b', 'a', 'b'), c('y'))
mapk(2, actual, predicted)

actual <- list(c(1, 5, 7, 9), c(2, 3), c(2, 5, 6))
predicted <- list(c(5, 6, 7, 8, 9), c(1, 2, 3), c(2, 4, 6, 8))
mapk(3, actual, predicted)

Metrics

Evaluation Metrics for Machine Learning

v0.1.4
BSD_3_clause + file LICENSE
Authors
Ben Hamner [aut, cph], Michael Frasco [aut, cre], Erin LeDell [ctb]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.