topk | R Documentation |
Determines if the true class label is among the top k
predicted probabilities for each observation.
topk(prob, observed, k)
prob |
Numeric matrix of predicted probabilities (observations x classes). Column names must correspond to class labels. |
observed |
Factor or vector of observed class labels. Must be present in |
k |
Integer; the number of top probabilities to consider. |
A data.frame
with columns topk
(logical indicator: TRUE
if observed class is in top-k) and observed
.
Other classifier evaluation:
rank_score()
probs <- matrix(c(0.1, 0.9, 0.8, 0.2, 0.3, 0.7), 3, 2, byrow=TRUE,
dimnames = list(NULL, c("A", "B")))
obs <- factor(c("B", "A", "B"))
topk(probs, obs, k=1)
topk(probs, obs, k=2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.