tobigithub / caret-machine-learning

Practical examples for the R caret machine learning package
MIT License
67 stars 50 forks source link

method "bag" in caret: all the RMSE metric values are missing: #19

Open tobigithub opened 8 years ago

tobigithub commented 8 years ago

Calling method bag without bagcontrol results in numerous errors, better would be to have a standard bagcontrol so the function train(x, y, method = "bag") could be called in a similar way like the working function train(x, y, method = "knn")

> test_reg_none_model <- train(x, y, method = "bag")
Something is wrong; all the RMSE metric values are missing:
      RMSE        Rsquared  
 Min.   : NA   Min.   : NA  
 1st Qu.: NA   1st Qu.: NA  
 Median : NA   Median : NA  
 Mean   :NaN   Mean   :NaN  
 3rd Qu.: NA   3rd Qu.: NA  
 Max.   : NA   Max.   : NA  
 NA's   :1     NA's   :1    
Error in train.default(x, y, method = "bag") : Stopping
In addition: There were 26 warnings (use warnings() to see them)

Solution: This does not work with a standard call train(x,y, "bag") , it requires bagControl parameters.

set.seed(123)
test_reg_none_model <- train(x, y, method = "bag", 
                             bagControl = bagControl(fit = ctreeBag$fit,
                                                     predict = ctreeBag$pred,
                                                     aggregate = ctreeBag$aggregate))