metrics | R Documentation |
ap_k
calculates Average Precision at K (ap@k
).
Please refer to Information retrieval wikipedia article
ndcg_k()
calculates Normalized Discounted Cumulative Gain at K (ndcg@k
).
Please refer to Discounted cumulative gain
ap_k(predictions, actual, ...)
ndcg_k(predictions, actual, ...)
predictions |
matrix of predictions. Predctions can be defined 2 ways:
|
actual |
sparse Matrix of relevant items. Each non-zero entry considered as relevant item.
Value of the each non-zero entry considered as relevance for calculation of |
... |
other arguments (not used at the moment) |
predictions = matrix(
c(5L, 7L, 9L, 2L),
nrow = 1
)
actual = matrix(
c(0, 0, 0, 0, 1, 0, 1, 0, 1, 0),
nrow = 1
)
actual = as(actual, "RsparseMatrix")
identical(rsparse::ap_k(predictions, actual), 1)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.