how can calculte mean average precision score in r ? there easy way?
i calculate follows. dont know if totally true or not..
pr = prediction(preds, labs) pf = performance(pr, "prec", "rec") # plot(pf) pf@x.name [1] "recall" pf@y.name [1] "precision" rec = pf@x.values[[1]] prec = pf@y.values[[1]] idxall = null for(i in 1:10){ = i/10 # find closest values in recall values 0, 0.1, 0.2, ... ,1.0 idx = which(abs(rec-i)==min(abs(rec-i))) # there more 1 value return, choose value in middle idx = idx[ceiling(length(idx)/2)] idxall = c(idxall, idx) } prec.mean = mean(prec[indx])
here's example metrics
package.
Comments
Post a Comment