mlr
mlr copied to clipboard
Test: Latest {klaR} update broke tests
Looks like an issue on their side at a first glance.
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)
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
I am having this same issue. Looking forward to a fix!
Writing a mail to the maintainer of {klaR} might help. This is not an {mlr} issue.
Yup, that makes sense! Will do. Thanks for the reply!
Hello, do you know if someone found a workaround to this issue?