From d1778a532dc095c4ee86157e93f204f5a91135f0 Mon Sep 17 00:00:00 2001 From: jcolomb Date: Tue, 30 Jan 2018 15:21:32 +0100 Subject: [PATCH] new code for plotting svm accuracy on test data --- .../SVM_logreg_plotresults.R | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 analysis/Rcode/analysis_for_paper1/SVM_logreg_plotresults.R diff --git a/analysis/Rcode/analysis_for_paper1/SVM_logreg_plotresults.R b/analysis/Rcode/analysis_for_paper1/SVM_logreg_plotresults.R new file mode 100644 index 0000000..4c05e2a --- /dev/null +++ b/analysis/Rcode/analysis_for_paper1/SVM_logreg_plotresults.R @@ -0,0 +1,46 @@ +# plot data from svm against logreg experiment + +load("C:/Users/cogneuro/Desktop/HCS_analysis/analysis/svm_logreg_174") +Plothist_bin <- function (Acc_cumm,i){ + dataplot = data.frame(Acc_cumm [-1,i]) + realacc=Acc_cumm [1,i] + title = names (Acc_cumm)[i] + names (dataplot) = "Accuracy_perm_grouping" + + k1 <- sum(as.numeric(dataplot$Accuracy_perm_grouping) >= + realacc) # One-tailed test + stat =print(zapsmall(binconf(k1, nrow(dataplot)-1, method='exact'))) # 95% CI by default + R= "not enough \npermutation done" + if (stat[1,2] > 0.05) R= "no difference spotted" + if (stat[1,3] < 0.05) R= paste0("different \nwith p < ",stat[1,3]) + + + p= ggplot(data=dataplot, aes(dataplot$Accuracy_perm_grouping)) + + geom_histogram(aes(y =..density..), + binwidth=0.09)+ + #xlab (paste0 ("accuracy of grouping with ",nrow(dataplot)," permutations performed")) + + xlim (c(-1,1))+ + #geom_density(col=3) + + geom_vline(xintercept=realacc, col=2)+ + labs(title= title, + x="",#paste0 ("accuracy of grouping with ",nrow(dataplot)," permutations performed"), + y="Proportion")+ + annotate("text", label = R, x = -1, y = 1, size = 4, colour = 1,hjust = 0) + return(p) +} + +#---- prepare plots +Nplot <- ncol(Acc_cumm) +pl_hist <- list() + +for (i in seq(1:Nplot)){ + pl_hist [[i]] = Plothist_bin(Acc_cumm,i) +} + +#pdf(file = paste0("svm_logregresults.pdf"), width = 15, height = 10) + +marrangeGrob(pl_hist , + ncol=3,nrow =3, top= paste0 ("accuracy of grouping with ",nrow(dataplot)," permutations performed")) + + +#dev.off() \ No newline at end of file