Open vjcitn opened 4 years ago
the example for plsda is blocked with \dontrun
but if you copy the code into a session
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") useSoftmax <- plsda(trainDescr, trainMDRR, ncomp = 5)
then the next line is
> confusionMatrix(predict(useBayes, testDescr), + testMDRR) Error in predict.NaiveBayes(object$probModel[[ncomp[i]]], as.data.frame(tmpPred[, : Not all variable names used in object found in newdata
> sessionInfo() R Under development (unstable) (2020-02-08 r77784) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: macOS Mojave 10.14.6 Matrix products: default BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.0.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] caret_6.0-85 ggplot2_3.2.1 lattice_0.20-38 rmarkdown_2.1 loaded via a namespace (and not attached): [1] Rcpp_1.0.3 lubridate_1.7.4 class_7.3-15 [4] assertthat_0.2.1 digest_0.6.23 ipred_0.9-9 [7] foreach_1.4.8 mime_0.9 R6_2.4.1 [10] plyr_1.8.5 stats4_4.0.0 evaluate_0.14 [13] highr_0.8 pillar_1.4.3 rlang_0.4.4 [16] lazyeval_0.2.2 rstudioapi_0.11 data.table_1.12.8 [19] miniUI_0.1.1.1 rpart_4.1-15 Matrix_1.2-18 [22] combinat_0.0-8 startup_0.14.0 splines_4.0.0 [25] gower_0.2.1 stringr_1.4.0 questionr_0.7.0 [28] munsell_0.5.0 shiny_1.4.0 compiler_4.0.0 [31] httpuv_1.5.2 xfun_0.12 pkgconfig_2.0.3 [34] htmltools_0.4.0 nnet_7.3-12 tidyselect_1.0.0 [37] tibble_2.1.3 prodlim_2019.11.13 codetools_0.2-16 [40] crayon_1.3.4 dplyr_0.8.4 withr_2.1.2 [43] later_1.0.0 MASS_7.3-51.5 recipes_0.1.9 [46] ModelMetrics_1.2.2.1 grid_4.0.0 nlme_3.1-143 [49] xtable_1.8-4 gtable_0.3.0 lifecycle_0.1.0 [52] magrittr_1.5 pROC_1.16.1 scales_1.1.0 [55] stringi_1.4.5 reshape2_1.4.3 promises_1.1.0 [58] timeDate_3043.102 pls_2.7-2 generics_0.0.2 [61] lava_1.6.6 klaR_0.6-15 iterators_1.0.12 [64] tools_4.0.0 glue_1.3.1 purrr_0.3.3 [67] fastmap_1.0.1 survival_3.1-8 colorspace_1.4-1 [70] knitr_1.28
same problem, looking for some help.
the example for plsda is blocked with \dontrun
but if you copy the code into a session
then the next line is