This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(ggplot2) | |
readRDS('ans-ps.RDS')->ss | |
do.call(rbind,lapply( | |
split(ss,paste(ss$met,ss$k)), | |
function(S){ | |
median(S$time[S$p==1])->bl | |
S$speedup<-bl/S$time | |
S | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setNames( | |
do.call(expand.grid,rep(list(c(T,F)),5)), | |
c("A","B","N1","N2","N3") | |
)->X | |
cbind(X,AoB=with(X,A|B),AnB=with(X,A&B),nA=!X$A)->X | |
factor(with(X,A!=B))->Y | |
data.frame(lapply(X,factor))->X | |
greedySVM<-function(X,Y,sel=names(X),err=Inf){ | |
#Empty selection is not interesting |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
precision<-function(y,p) sum(y&p)/sum(p) | |
recall<-function(y,p) sum(y&p)/sum(y) | |
Fscore<-function(y,p) 2/(1+sum(y|p)/sum(y&p)) | |
precisionS<-function(Y,P) mean(P%in%Y) | |
recallS<-function(Y,P) mean(Y%in%P) | |
FscoreS<-function(Y,P) mean(c(Y,P)%in%intersect(P,Y)) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#AUROC calculation code | |
auroc<-function(score,cls){ | |
n1<-sum(!cls); sum(cls)->n2; | |
U<-sum(rank(score)[!cls])-n1*(n1+1)/2; | |
return(1-U/n1/n2); | |
} | |
#... as a cryptic one-liner | |
auroc1l<-function(score,cls) | |
mean(rank(score)[cls]-1:sum(cls))/sum(!cls) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat(sprintf("::%s\n",paste(replicate(4,paste(sample(z,4,rep=TRUE),collapse="")),collapse=":"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s9<-function(M,iters=1){ | |
M*0+9->n; | |
n[,1]<-n[1,]<-n[,ncol(n)]<-n[nrow(n),]<-6; | |
n[1,1]<-n[1,ncol(n)]<-n[nrow(n),1]<-n[nrow(n),ncol(n)]<-4; | |
for(e in 1:iters){ | |
s<-M+ | |
cbind(M[,-1],0)+ | |
cbind(0,M[,-ncol(M)])+ | |
rbind(M[-1,],0)+ | |
rbind(0,M[-nrow(M),])+ |