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

timingSamps error using formula interface #420

Closed
LluisRamon opened this issue May 1, 2016 · 1 comment
Closed

timingSamps error using formula interface #420

LluisRamon opened this issue May 1, 2016 · 1 comment

Comments

@LluisRamon
Copy link
Contributor

@LluisRamon LluisRamon commented May 1, 2016

Hi Max,

I think I have found a bug. I followed your instructions:

Minimal dataset:

library("caret")

data(kyphosis, package = "rpart")

fitControl <- trainControl(method = "cv",
                           timingSamps = 5)

Minimal, runnable code:

# Using formula interface doesn't work
train(Kyphosis ~ ., data = kyphosis, 
      method = "rpart", 
      trControl = fitControl)
# Error in eval(expr, envir, enclos) : object 'Age' not found 

# Using non-formula interface works
train(x = kyphosis[, -1], y = kyphosis$Kyphosis,
      method = "rpart",
      trControl = fitControl)

Session Info:

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

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] 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] rpart_4.1-10    caret_6.0-68    ggplot2_2.0.0   lattice_0.20-33

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.3        magrittr_1.5       splines_3.2.3      MASS_7.3-44        munsell_0.4.2     
 [6] colorspace_1.2-6   foreach_1.4.3      minqa_1.2.4        stringr_1.0.0      car_2.1-2         
[11] plyr_1.8.3         tools_3.2.3        nnet_7.3-11        pbkrtest_0.4-6     parallel_3.2.3    
[16] grid_3.2.3         gtable_0.1.2       nlme_3.1-126       mgcv_1.8-7         quantreg_5.21     
[21] e1071_1.6-7        class_7.3-14       MatrixModels_0.4-1 iterators_1.0.8    lme4_1.1-11       
[26] Matrix_1.2-3       nloptr_1.0.4       reshape2_1.4.1     codetools_0.2-14   stringi_1.0-1     
[31] compiler_3.2.3     scales_0.3.0       stats4_3.2.3       SparseM_1.7  

Thank you very much for your great package!!

topepo added a commit that referenced this issue May 31, 2016
@topepo
Copy link
Owner

@topepo topepo commented May 31, 2016

It was related to the assumption that the predictors would be in a data frame. It works now...

Thanks,

Max

> library("caret")
Loading required package: lattice
Loading required package: ggplot2
Need help? Try the ggplot2 mailing list:
http://groups.google.com/group/ggplot2.
> 
> data(kyphosis, package = "rpart")
> 
> fitControl <- trainControl(method = "cv",
+                            timingSamps = 5)
> train(Kyphosis ~ ., data = kyphosis, 
+       method = "rpart", 
+       trControl = fitControl)
Loading required package: rpart
CART 

81 samples
 3 predictor
 2 classes: 'absent', 'present' 

No pre-processing
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 73, 74, 72, 72, 73, 74, ... 
Resampling results across tuning parameters:

  cp          Accuracy   Kappa     
  0.00000000  0.8244048  0.41896846
  0.01960784  0.8244048  0.41896846
  0.17647059  0.7535714  0.04381318

Accuracy was used to select the optimal model using  the largest value.
The final value used for the model was cp = 0.01960784. 
> # Error in eval(expr, envir, enclos) : object 'Age' not found 
> 
> # Using non-formula interface works
> train(x = kyphosis[, -1], y = kyphosis$Kyphosis,
+       method = "rpart",
+       trControl = fitControl)
CART 

81 samples
 3 predictor
 2 classes: 'absent', 'present' 

No pre-processing
Resampling: Cross-Validated (10 fold) 
Summary of sample sizes: 73, 73, 73, 73, 73, 72, ... 
Resampling results across tuning parameters:

  cp          Accuracy   Kappa    
  0.00000000  0.7940476  0.3621554
  0.01960784  0.7940476  0.3621554
  0.17647059  0.7690476  0.1507268

Accuracy was used to select the optimal model using  the largest value.
The final value used for the model was cp = 0.01960784. 
@topepo topepo closed this May 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.