[R] Using multicores in R

moriah moriahcohen at gmail.com
Tue Dec 4 13:26:13 CET 2012


Thanks for the help, 

Perhaps I should elaborate a bit, I am working on bioinformatics  project in
which I am trying to run a forward selection algorithm for machine learning
classification of two biological conditions. 
At each iteration I want to find the gene that in addition to those I have
found already does the best classification.

It looks something like this:

for (j in 1:5030)
  { 
  tp <- 0;
  for (i in 1:5030)
  {
    if (!(i %in% idx))
    {

      classifier<-naiveBayes(trn[,c(i,idx)], trn[,20118]) 
      tbl <-table(predict(classifier, trn[,-20118]), trn[,20118])
      success <- (tbl[[1]] +tbl[[4]])/(tbl[[1]] +tbl[[4]]+tbl[[2]]+tbl[[3]])

      if (success > tp)
      {
        tp <- success
        ind <- i
        gene <- names(trn)[i]
      }
    }
    
  }
  idx <- c(idx,ind)
  res <- rbind(res, data.frame(Iteration=j,Success=tp*100,Gene=gene))
}

I am no expert when it comes to programming so I am not sure how can I
optimize my relatively primitive code in the best way...

Thanks,
Moriah





--
View this message in context: http://r.789695.n4.nabble.com/Using-multicores-in-R-tp4651808p4652034.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list