mlr icon indicating copy to clipboard operation
mlr copied to clipboard

Test: Latest {klaR} update broke tests

Open pat-s opened this issue 5 years ago • 5 comments

Looks like an issue on their side at a first glance.

Build

caret::plsda() calls klaR:::predict.NaiveBayes() internally.

── 1. Error: classif_plsdaCaret_binary (@test_classif_plsdaCaret.R#25)  ────────
Not all variable names used in object found in newdata
Backtrace:
 1. stats::predict(m, newdata = newx, type = "class")
 2. caret:::predict.plsda(m, newdata = newx, type = "class")
 4. klaR:::predict.NaiveBayes(...)

Reprex

library("caret")
#> Loading required package: lattice
#> Loading required package: ggplot2

data(mdrr)
set.seed(1)
inTrain <- sample(seq(along = mdrrClass), 450)

nzv <- nearZeroVar(mdrrDescr)
filteredDescr <- mdrrDescr[, -nzv]

training <- filteredDescr[inTrain, ]
test <- filteredDescr[-inTrain, ]
trainMDRR <- mdrrClass[inTrain]
testMDRR <- mdrrClass[-inTrain]

preProcValues <- preProcess(training)

trainDescr <- predict(preProcValues, training)
testDescr <- predict(preProcValues, test)

useBayes <- plsda(trainDescr, trainMDRR, ncomp = 5,
  probMethod = "Bayes")
predict(useBayes, testDescr)
#> Error in predict.NaiveBayes(object$probModel[[ncomp[i]]], as.data.frame(tmpPred[, : Not all variable names used in object found in newdata

# var names are actually the same
all.equal(names(trainDescr),
  names(testDescr))
#> [1] TRUE

Created on 2020-02-21 by the reprex package (v0.3.0)

pat-s avatar Feb 21 '20 13:02 pat-s

Disabled the test for now to have a green CI build. Maintainer is informed -> re-enable when fixed.

https://github.com/mlr-org/mlr/blob/master/tests/testthat/test_classif_plsdaCaret.R

pat-s avatar Feb 24 '20 07:02 pat-s

I am having this same issue. Looking forward to a fix!

shakeeljessa avatar Apr 07 '20 19:04 shakeeljessa

Writing a mail to the maintainer of {klaR} might help. This is not an {mlr} issue.

pat-s avatar Apr 07 '20 20:04 pat-s

Yup, that makes sense! Will do. Thanks for the reply!

shakeeljessa avatar Apr 07 '20 22:04 shakeeljessa

Hello, do you know if someone found a workaround to this issue?

gerardsapes avatar Nov 18 '22 20:11 gerardsapes