Skip to content

Instantly share code, notes, and snippets.

@kaz-yos
Last active August 2, 2016 10:02
Show Gist options
  • Save kaz-yos/21c014c65cc7a04d4369e2d8d2afa868 to your computer and use it in GitHub Desktop.
Save kaz-yos/21c014c65cc7a04d4369e2d8d2afa868 to your computer and use it in GitHub Desktop.
## オリジナル
result<-NULL
for(i in 1:20000){
result<-c(result,roc(...))
}
## 2000-vectorを最初に作成
result <- as.numeric(rep(NA,2*10^4))
for(i in 1:20000){
result[i] <- roc(...)
}
## foreach初期化コードをさける
result <- foreach(i = seq_len(2*10^4)) %do% {
roc(...)
}
## foreachで並列化
result <- foreach(i = seq_len(2*10^4)) %dopar% {
roc(...)
}
## bootを使用
bootFun <- function(data, i) {
roc(data = data[i,], ...)
}
boot(data = , statistic = , R = , parallel = "multicore", ncpus = foreach::getDoParWorkers())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment