acc_topk: get top k accuracy

View source: R/utils.R

acc_topkR Documentation

get top k accuracy

Description

get top k accuracy

Usage

acc_topk(pred_topk, truth)

Arguments

pred_topk

a matrix of integers; each row indicates top 1, 2, ..., k causes

truth

a vector of integers; its length equals the number of rows in pred_topk.

Value

numeric; between 0 and 1; the higher the more accurate.

Examples


xx <- matrix(c(0.3,0.1,0.2,0.4,
               0.4,0.1,0.3,0.2),nrow=2,ncol=4,byrow=TRUE)
pred_top2 <- get_topk_COD(xx,2)
acc_topk(pred_top2,c(4,2))


zhenkewu/doubletree documentation built on Oct. 21, 2023, 7:04 a.m.