Description Usage Arguments Details See Also Examples

`apk`

computes the average precision at k, in the context of information
retrieval problems.

1 | ```
apk(k, actual, predicted)
``` |

`k` |
The number of elements of |

`actual` |
The ground truth vector of relevant documents. The vector can contain
any numeric or character values, order does not matter, and the
vector does not need to be the same length as |

`predicted` |
The predicted vector of retrieved documents. The vector can
contain any numeric of character values. However, unlike |

`apk`

loops over the first k values of `predicted`

. For each value, if
the value is contained within `actual`

and has not been predicted before,
we increment the number of sucesses by one and increment our score by the number
of successes divided by k. Then, we return our final score divided by the number
of relevant documents (i.e. the length of `actual`

).

`apk`

will return `NaN`

if `length(actual)`

equals `0`

.

1 2 3 |

```
[1] 0.5555556
```

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.