nearZeroVar in caret returns vary when using foreach

222 views Asked by At

I've noticed that setting foreach=TRUE in nearZeroVar returns a different vector of integers (always seems to be 1) than foreach=FALSE. The metrics returned by saveMetrics=TRUE do not differ. Any suggestions on what I might be missing?

frame = data.frame(seq(1:100),seq(1:100),c(rep(0,99),1))
frame = cbind(frame,frame)
names(frame) = c("a","b","c","d","e","f")

nearZeroVar(frame,allowParallel=TRUE,foreach=TRUE,saveMetrics=TRUE)

  freqRatio percentUnique zeroVar   nzv
a         1           100   FALSE FALSE
b         1           100   FALSE FALSE
c        99             2   FALSE  TRUE
d         1           100   FALSE FALSE
e         1           100   FALSE FALSE
f        99             2   FALSE  TRUE

nearZeroVar(frame,allowParallel=TRUE,foreach=FALSE,saveMetrics=TRUE)

  freqRatio percentUnique zeroVar   nzv
a         1           100   FALSE FALSE
b         1           100   FALSE FALSE
c        99             2   FALSE  TRUE
d         1           100   FALSE FALSE
e         1           100   FALSE FALSE
f        99             2   FALSE  TRUE

nearZeroVar(frame,allowParallel=TRUE,foreach=TRUE)
[1] 1 1

nearZeroVar(frame,allowParallel=TRUE,foreach=FALSE)
[1] 3 6
0

There are 0 answers