Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- fast <- function(input, truth){
- input_clust <- outer(input,input,"==")
- truth_clust <- outer(truth,truth,"==")
- tp <- (input_clust & truth_clust)
- fp <- input_clust & !truth_clust
- tn <- !input_clust & !truth_clust
- fn <- !input_clust & truth_clust
- tp <- sum(tp & upper.tri(tp))
- fp <- sum(fp & upper.tri(fp))
- tn <- sum(tn & upper.tri(tn))
- fn <- sum(fn & upper.tri(fn))
- precision = 0
- recall = 0
- f_1 = 0
- if((tp>0)){
- precision = tp/(tp+fp)
- }
- if((tp>0)){
- recall = tp/(tp+fn)
- }
- if((precision > 0 & recall > 0)){
- f_1=(2*precision*recall)/(precision+recall)
- }
- return (c(precision,recall,f_1))
- }
Add Comment
Please, Sign In to add comment