Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: Latest {klaR} update broke tests #2738

Open
pat-s opened this issue Feb 21, 2020 · 5 comments
Open

Test: Latest {klaR} update broke tests #2738

pat-s opened this issue Feb 21, 2020 · 5 comments
Labels

Comments

@pat-s
Copy link
Member

pat-s commented Feb 21, 2020

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 pat-s added the type-bug label Feb 21, 2020
@pat-s
Copy link
Member Author

pat-s commented Feb 24, 2020

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

@shakeeljessa
Copy link

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

@pat-s
Copy link
Member Author

pat-s commented Apr 7, 2020

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

@shakeeljessa
Copy link

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

@gerardsapes
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants