topepo / caret

caret (Classification And Regression Training) R package that contains misc functions for training and plotting classification and regression models
http://topepo.github.io/caret/index.html
1.6k stars 637 forks source link

C5.0 Plot #412

Closed SteveBronder closed 8 years ago

SteveBronder commented 8 years ago

Minimal, reproducible example:

library(caret)
data(iris)

y <- iris$Species
x <- iris[,-5]
c50Fit1 <- train(x = x, y = y,
                 method = "C5.0",
                 metric = "Kappa",
                 trControl = trainControl(method = "cv",
                                          number = 10,
                                          classProbs = TRUE),
                 tuneGrid = expand.grid(trials = c(1:4)*4,
                                        model = c("rules","tree"),
                                        winnow = c("false","true")))

The following error messages (and a few others) arise

In Ops.factor(x$winnow) : ‘!’ not meaningful for factors

And also, attempting to use the print function leads to

plot(c50Fit1)
Error in ifelse(dat$winnow, "Winnowing", "No Winnowing") : 
  invalid to change the storage mode of a factor

Session Info:

>sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.4 LTS

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plyr_1.8.3          C50_0.1.0-24        caret_6.0-62        ggplot2_2.0.0       lattice_0.20-33    
[6] RevoUtilsMath_3.2.3

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.2        compiler_3.2.3     nloptr_1.0.4       iterators_1.0.8    class_7.3-14      
 [6] tools_3.2.3        partykit_1.0-4     lme4_1.1-10        nlme_3.1-122       gtable_0.1.2      
[11] mgcv_1.8-9         Matrix_1.2-3       foreach_1.4.3      yaml_2.1.13        parallel_3.2.3    
[16] SparseM_1.7        e1071_1.6-7        stringr_1.0.0      knitr_1.11         MatrixModels_0.4-1
[21] stats4_3.2.3       grid_3.2.3         nnet_7.3-11        survival_2.38-3    minqa_1.2.4       
[26] reshape2_1.4.1     car_2.1-1          magrittr_1.5       whisker_0.3-2      scales_0.3.0      
[31] codetools_0.2-14   MASS_7.3-45        splines_3.2.3      pbkrtest_0.4-4     colorspace_1.2-6  
[36] quantreg_5.19      stringi_1.0-1      slidify_0.4.5      munsell_0.4.2      markdown_0.7.7  
topepo commented 8 years ago

Use TRUE, FALSE instead of "false","true"