knitr::opts_chunk$set(cache = FALSE)
resFiles <- list.files("outputs/")
for (fileName in resFiles) {
  load(paste0("outputs/", fileName))
}
library(VSURF)

toys data

data(toys)

Sequential with randomForest

set.seed(556264)
toysRF <- VSURF(toys$x, toys$y)
summary(toysRF)
save(toysRF, file = "outputs/toysRF.Rdata")

Sequential with ranger

set.seed(475073)
toysRg <- VSURF(toys$x, toys$y, RFimplem = "ranger")
summary(toysRg)
save(toysRg, file = "outputs/toysRg.Rdata")

Parallel with randomForest

ncores <- 24
set.seed(364693, kind = "L'Ecuyer-CMRG")
toysRFPara <- VSURF(toys$x, toys$y, parallel = TRUE, clusterType = "FORK", ncores = ncores)
summary(toysRFPara)
save(toysRFPara, file = "outputs/toysRFPara.Rdata")

Parallel with ranger

Fork

set.seed(850162, kind = "L'Ecuyer-CMRG")
toysRgPara <- VSURF(toys$x, toys$y, RFimplem = "ranger", parallel = TRUE, clusterType = "FORK", ncores = ncores)
summary(toysRgPara)
save(toysRgPara, file = "outputs/toysRgPara.Rdata")

Internal

set.seed(289817)
toysRgParaInter <- VSURF(toys$x, toys$y, RFimplem = "ranger", parallel = TRUE, clusterType = "ranger", ncores = ncores)
summary(toysRgParaInter)
save(toysRgParaInter, file = "outputs/toysRgParaInter.Rdata")

spam data

data("spam", package = "kernlab")
set.seed(9146301)
levels(spam$type) <- c("ok", "spam")
yTable <- table(spam$type)
indApp <- c(sample(1:yTable[2], yTable[2]/2),
            sample((yTable[2] + 1):nrow(spam), yTable[1]/2))
spamApp <- spam[indApp, ]
spamTest <- spam[-indApp, ]
ncores <- 32

Threshold step

spamThres <- VSURF_thres(type~., spamApp, parallel = TRUE, ncores = ncores, clusterType="FORK")
save(spamThres, file = "outputs/spamThres.Rdata")
spamThres$comput.time
spamRgThres <- VSURF_thres(type~., spamApp, parallel = TRUE, ncores = ncores, clusterType="FORK", RFimplem = "ranger")
save(spamRgThres, file = "outputs/spamRgThres.Rdata")
spamRgThres$comput.time
spamRgThresParaRg <- VSURF_thres(type~., spamApp, parallel = TRUE, ncores = ncores, clusterType = "ranger", RFimplem = "ranger")
save(spamRgThresParaRg, file = "outputs/spamRgThresParaRg.Rdata")
spamRgThresParaRg$comput.time

Interpretation step

spamInterp <- VSURF_interp(type~., spamApp, vars = spamThres$varselect.thres, parallel = TRUE, ncores = ncores, clusterType = "FORK")
save(spamInterp, file = "outputs/spamInterp.Rdata")
spamInterp$comput.time
spamRgInterp <- VSURF_interp(type~., spamApp, vars = spamThres$varselect.thres, parallel = TRUE, ncores = ncores, clusterType = "FORK", RFimplem = "ranger")
save(spamRgInterp, file = "outputs/spamRgInterp.Rdata")
spamRgInterp$comput.time
spamRgInterpParaRg <- VSURF_interp(type~., spamApp, vars = spamThres$varselect.thres, parallel = TRUE, ncores = ncores, clusterType = "ranger", RFimplem = "ranger")
save(spamRgInterpParaRg, file = "outputs/spamRgInterpParaRg.Rdata")
spamRgInterpParaRg$comput.time
spamRbInterp <- VSURF_interp(type~., spamApp, vars = spamThres$varselect.thres, parallel = TRUE, ncores = ncores, clusterType = "FORK", RFimplem = "Rborist")
save(spamRbInterp, file = "outputs/spamRbInterp.Rdata")
spamRbInterp$comput.time
spamRbInterpParaRb <- VSURF_interp(type~., spamApp, vars = spamThres$varselect.thres, parallel = TRUE, ncores = ncores, clusterType = "Rborist", RFimplem = "Rborist")
save(spamRbInterpParaRb, file = "outputs/spamRbInterpParaRb.Rdata")
spamRbInterpParaRb$comput.time

Prediction step

spamPred <- VSURF_pred(type~., spamApp, err.interp = spamInterp$err.interp, varselect.interp = spamInterp$varselect.interp)
save(spamPred, file = "outputs/spamPred.Rdata")
spamPred$comput.time
spamRgPred <- VSURF_pred(type~., spamApp, err.interp = spamInterp$err.interp, varselect.interp = spamInterp$varselect.interp, RFimplem = "ranger")
save(spamRgPred, file = "outputs/spamRgPred.Rdata")
spamRgPred$comput.time
spamRgPredParaRg <- VSURF_pred(type~., spamApp, err.interp = spamInterp$err.interp, varselect.interp = spamInterp$varselect.interp, RFimplem = "ranger", num.threads = ncores)
save(spamRgPredParaRg, file = "outputs/spamRgPredParaRg.Rdata")
spamRgPredParaRg$comput.time
spamRbPred <- VSURF_pred(type~., spamApp, err.interp = spamInterp$err.interp, varselect.interp = spamInterp$varselect.interp, RFimplem = "Rborist")
save(spamRbPred, file = "outputs/spamRbPred.Rdata")
spamRbPred$comput.time
spamRbPredParaRb <- VSURF_pred(type~., spamApp, err.interp = spamInterp$err.interp, varselect.interp = spamInterp$varselect.interp, RFimplem = "Rborist", nThread = ncores)
save(spamRbPredParaRb, file = "outputs/spamRbPredParaRb.Rdata")
spamRbPredParaRb$comput.time

vac18 data

data("vac18", package = "mixOmics")
geneExpr <- vac18$genes
stimu <- vac18$stimulation
ncores <- 3

Parallel with randomForest

vacRF <- VSURF(x = geneExpr, y = stimu, parallel = TRUE, ncores = ncores, clusterType = "FORK")
summary(vacRF)
save(vacRF, file = "outputs/vacRF.Rdata")

Parallel with ranger

vacRgThres <- VSURF_thres(x = geneExpr, y = stimu, parallel = TRUE, ncores = ncores, RFimplem = "ranger", clusterType = "FORK")
vacRgThres$comput.time
save(vacRgThres, file = "outputs/vacRgThres.Rdata")
vacRgInterp <- VSURF_interp(x = geneExpr, y = stimu, parallel = TRUE, ncores = ncores, RFimplem = "ranger", clusterType = "FORK", vars = vacRF$varselect.thres)
vacRgInterp$comput.time
save(vacRgInterp, file = "outputs/vacRgInterp.Rdata")
vacRgPred <- VSURF_pred(x = geneExpr, y = stimu, RFimplem = "ranger", varselect.interp = vacRF$varselect.interp, err.interp = vacRF$err.interp)
vacRgPred$comput.time
save(vacRgPred, file = "outputs/vacRgPred.Rdata")


robingenuer/VSURF documentation built on July 15, 2024, 8:18 p.m.