Title: Caret-Multple-Model-Runs

Libraries:

knitr::opts_chunk$set(echo = TRUE, cache = TRUE)

Libraries = c("readr", "doMC", "mlbench", "caret", "kernlab", "e1071")

# Install if not present
for(p in Libraries){
    if(!require(p, character.only = TRUE)) { install.packages(p) }
    library(p, character.only = TRUE)
}

Import Data:

test_harness_paa <- read_csv("test_harness_paa.csv")
## Parsed with column specification:
## cols(
##   .default = col_double(),
##   Class = col_character(),
##   id = col_character()
## )
## See spec(...) for full column specifications.
test_harness_paa <- test_harness_paa[,-c(2,3)]
Class <- as.factor(test_harness_paa$Class)

Run “lvq”, “gbm”, “svm” M.L. Models

registerDoMC(cores=3)

start_time <- Sys.time() # Start timer

control <- trainControl(method="repeatedcv", number=10, repeats=3)

# train the LVQ model
set.seed(7)
modelLvq <- train(Class~., data=test_harness_paa, method="lvq", trControl=control)

# train the GBM model
set.seed(7)
modelGbm <- train(Class~., data=test_harness_paa, method="gbm", trControl=control, verbose=FALSE)

# train the SVM model
set.seed(7)
modelSvm <- train(Class~., data=test_harness_paa, method="svmRadial", trControl=control)

end_time <- Sys.time()   # End timer
end_time - start_time    # Display time
## Time difference of 4.251866 mins

Machine Settings:

Sys.info()[c(1:3,5)]
##                                               sysname 
##                                               "Linux" 
##                                               release 
##                                   "4.15.0-47-generic" 
##                                               version 
## "#50~16.04.1-Ubuntu SMP Fri Mar 15 16:06:21 UTC 2019" 
##                                               machine 
##                                              "x86_64"
sessionInfo()
## R version 3.4.4 (2018-03-15)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Linux Mint 18.3
## 
## Matrix products: default
## BLAS: /usr/lib/libblas/libblas.so.3.6.0
## LAPACK: /usr/lib/lapack/liblapack.so.3.6.0
## 
## locale:
##  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
##  [3] 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   
##  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] parallel  stats     graphics  grDevices utils     datasets  methods  
## [8] base     
## 
## other attached packages:
##  [1] e1071_1.7-0.1    kernlab_0.9-27   caret_6.0-81     ggplot2_3.1.0   
##  [5] lattice_0.20-38  mlbench_2.1-1    doMC_1.3.5       iterators_1.0.10
##  [9] foreach_1.4.4    readr_1.3.1     
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.0         lubridate_1.7.4    class_7.3-14      
##  [4] assertthat_0.2.0   digest_0.6.18      ipred_0.9-8       
##  [7] R6_2.3.0           plyr_1.8.4         stats4_3.4.4      
## [10] evaluate_0.12      pillar_1.3.1       rlang_0.3.0.1     
## [13] lazyeval_0.2.1     data.table_1.11.8  rpart_4.1-13      
## [16] Matrix_1.2-15      rmarkdown_1.11     splines_3.4.4     
## [19] gower_0.1.2        stringr_1.3.1      munsell_0.5.0     
## [22] compiler_3.4.4     xfun_0.4           pkgconfig_2.0.2   
## [25] gbm_2.1.5          htmltools_0.3.6    nnet_7.3-12       
## [28] tidyselect_0.2.5   gridExtra_2.3      tibble_1.4.2      
## [31] prodlim_2018.04.18 codetools_0.2-16   crayon_1.3.4      
## [34] dplyr_0.7.8        withr_2.1.2        MASS_7.3-51.1     
## [37] recipes_0.1.4      ModelMetrics_1.2.2 grid_3.4.4        
## [40] nlme_3.1-137       gtable_0.2.0       magrittr_1.5      
## [43] scales_1.0.0       stringi_1.2.4      reshape2_1.4.3    
## [46] bindrcpp_0.2.2     timeDate_3043.102  generics_0.0.2    
## [49] lava_1.6.4         tools_3.4.4        glue_1.3.0        
## [52] purrr_0.2.5        hms_0.4.2          survival_2.43-3   
## [55] yaml_2.2.0         colorspace_1.3-2   knitr_1.21        
## [58] bindr_0.1.1

EOF