Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Bug with RStudio + doMC + caret combination
- #
- # (1) Problem when calling PenalizedLDA
- #
- # With registerDoMC the libraries called within train() do not get loaded
- #
- # PenalizedLDA : penalizedLDA and flsa do not get loaded
- # LDA : MASS does not get loaded
- # nb: klaR does not get loaded
- #
- # (The libraries are loaded in createModel.R and predictionFunction.R)
- #
- # This results in an error when calling train
- # Error in names(resamples) <- gsub("^\\.", "", names(resamples)) :
- # attempt to set an attribute on NULL
- # registerDoSEQ does not have this problem
- # This problem is unique to RStudio, the default R shell does not have this
- # problem
- rm(list=ls(all = TRUE))
- library(caret)
- library(doMC)
- registerDoMC()
- #registerDoSEQ()
- data(mdrr)
- nearZeroVar_classwise <- function(X,y) (unique(unlist(dlply(data.frame(X=X, y=y),.(y),function(Z) nearZeroVar(Z[,1:NCOL(X)])))))
- X <- mdrrDescr
- y <- mdrrClass
- X <- X[,-nearZeroVar_classwise(X,y)]
- X <- X[,-findCorrelation(cor(X), cutoff=0.75)]
- # library(klaR)
- # detach("package:klaR")
- ptm <- proc.time()
- (fit <- train(X, y, method="nb", trControl=trainControl(method="boot", number=5)))
- print(proc.time() - ptm)
- # library(penalizedLDA)
- # library(flsa)
- # detach("package:penalizedLDA")
- # detach("package:flsa")
- ptm <- proc.time()
- (fit <- train(X, y, method="lda", trControl=trainControl(method="boot", number=5)))
- print(proc.time() - ptm)
- # library(MASS)
- # detach("package:MASS")
- ptm <- proc.time()
- (fit <- train(X, y, method="PenalizedLDA", trControl=trainControl(method="boot", number=5)))
- print(proc.time() - ptm)
Add Comment
Please, Sign In to add comment