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.61k stars 636 forks source link

train.default object not found #676

Closed lgreski closed 7 years ago

lgreski commented 7 years ago

If you are making a feature request or starting a discussion, you can ignore everything below and go wild =D

If you are filing a bug, make sure these boxes are checked before submitting your issue— thank you!

Minimal, reproducible example:

Code generates an object not found error in caret_6.0-76, works in caret_6.0-71. This is from a lecture in the Johns Hopkins University Practical Machine Learning course, and when students try to reproduce the lecture code, it no longer produces the expected result.

Minimal, runnable code:

library(caret)
args(train.default)

Session Info:

>sessionInfo()
R version 3.4.0 (2017-04-21)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

other attached packages:
[1] caret_6.0-76    ggplot2_2.2.1   lattice_0.20-35

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.10       magrittr_1.5       splines_3.4.0      MASS_7.3-47        munsell_0.4.3      colorspace_1.3-2  
 [7] foreach_1.4.3      minqa_1.2.4        stringr_1.2.0      car_2.1-4          plyr_1.8.4         tools_3.4.0       
[13] parallel_3.4.0     nnet_7.3-12        pbkrtest_0.4-7     grid_3.4.0         gtable_0.2.0       nlme_3.1-131      
[19] mgcv_1.8-17        quantreg_5.33      MatrixModels_0.4-1 iterators_1.0.8    lme4_1.1-13        lazyeval_0.2.0    
[25] tibble_1.3.0       Matrix_1.2-9       nloptr_1.0.4       reshape2_1.4.2     ModelMetrics_1.1.0 codetools_0.2-15  
[31] stringi_1.1.5      compiler_3.4.0     scales_0.4.1       stats4_3.4.0       SparseM_1.77      
>

Code works as expected in earlier version of caret:

caretargsexample

regards,

Len

topepo commented 7 years ago

It is not exposed to the user (this is not uncommon). Use the namespace to see it:

> args(caret:::train.default)
function (x, y, method = "rf", preProcess = NULL, ..., weights = NULL, 
    metric = ifelse(is.factor(y), "Accuracy", "RMSE"), maximize = ifelse(metric %in% 
        c("RMSE", "logLoss"), FALSE, TRUE), trControl = trainControl(), 
    tuneGrid = NULL, tuneLength = ifelse(trControl$method == 
        "none", 1, 3)) 
NULL
> methods("train")
[1] train.default* train.formula* train.recipe* 
see '?methods' for accessing help and source code
lgreski commented 7 years ago

So the object was changed to remove its visibility to the user between release 6.0-71 and 6.0-76. Thanks for directing me to the namespace. I also alerted the staff at Johns Hopkins to update their lecture content to reference the namespace.

regards,

Len