library(e1071) library(MLmetrics) library(ROCR) data = read.csv('../bayes.csv') ytest = data[,1] pred_m1 = data[,2] pred_m2 = data[,3] # Threshold 0.5 pred_m1[pred_m1 >= 0.5] = 1 pred_m1[pred_m1 < 0.5] = 0 m1 = prediction(pred_m1, ytest) ROCcurve <- performance(m1, "tpr", "fpr") plot(ROCcurve, col = "blue") abline(0,1, col = "grey") performance(m1, "auc") pred_m2 = data[,3] pred_m2[pred_m2 < 0.5] = 0 pred_m2[pred_m2 >= 0.5] = 1 ConfusionMatrix(pred_m2, ytest) m2 = prediction(pred_m2, ytest) # Define positive class when calling Rec/Prec/F1 Recall(pred_m2, ytest, '1') Precision(pred_m2, ytest, '1') F1_Score(pred_m2, ytest, '1') ROCcurve2 <- performance(m2, "tpr", "fpr") plot(ROCcurve2, col = "red") # Get the AUC performance(m2, "auc")