# Demo Dataset: Diabetes
library(caret)
## Warning: package 'caret' was built under R version 3.6.1
## Loading required package: lattice
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 3.6.1
library(mlbench)
## Warning: package 'mlbench' was built under R version 3.6.1
data("PimaIndiansDiabetes")
diabetes <- PimaIndiansDiabetes
str(diabetes)
## 'data.frame':    768 obs. of  9 variables:
##  $ pregnant: num  6 1 8 1 0 5 3 10 2 8 ...
##  $ glucose : num  148 85 183 89 137 116 78 115 197 125 ...
##  $ pressure: num  72 66 64 66 40 74 50 0 70 96 ...
##  $ triceps : num  35 29 0 23 35 0 32 0 45 0 ...
##  $ insulin : num  0 0 0 94 168 0 88 0 543 0 ...
##  $ mass    : num  33.6 26.6 23.3 28.1 43.1 25.6 31 35.3 30.5 0 ...
##  $ pedigree: num  0.627 0.351 0.672 0.167 2.288 ...
##  $ age     : num  50 31 32 21 33 30 26 29 53 54 ...
##  $ diabetes: Factor w/ 2 levels "neg","pos": 2 1 2 1 2 1 2 1 2 2 ...
# Train and Test Baseline KNN Model
set.seed(188)
train_index <- createDataPartition(diabetes$diabetes, p = 0.7, list = FALSE)

diabetes_train <- diabetes[train_index, ]
diabetes_test <- diabetes[-train_index, ]

model_knn <- train(diabetes ~ ., data = diabetes_train, method = "knn")
predict_knn <- predict(model_knn, newdata = diabetes_test)

# Measure Model Performance: Hold-Out Method
confusionMatrix(predict_knn, diabetes_test$diabetes)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction neg pos
##        neg 128  38
##        pos  22  42
##                                           
##                Accuracy : 0.7391          
##                  95% CI : (0.6773, 0.7946)
##     No Information Rate : 0.6522          
##     P-Value [Acc > NIR] : 0.002949        
##                                           
##                   Kappa : 0.3969          
##                                           
##  Mcnemar's Test P-Value : 0.052808        
##                                           
##             Sensitivity : 0.8533          
##             Specificity : 0.5250          
##          Pos Pred Value : 0.7711          
##          Neg Pred Value : 0.6563          
##              Prevalence : 0.6522          
##          Detection Rate : 0.5565          
##    Detection Prevalence : 0.7217          
##       Balanced Accuracy : 0.6892          
##                                           
##        'Positive' Class : neg             
## 
# Measure Model Performance: Bootstrap Method
print(model_knn)
## k-Nearest Neighbors 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## No pre-processing
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 538, 538, 538, 538, 538, 538, ... 
## Resampling results across tuning parameters:
## 
##   k  Accuracy   Kappa    
##   5  0.7016545  0.3303555
##   7  0.7141886  0.3545458
##   9  0.7201809  0.3631783
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was k = 9.
# Pre-process Data
pre_process <- preProcess(diabetes_train, method = c("scale", "center"))
pre_process
## Created from 538 samples and 9 variables
## 
## Pre-processing:
##   - centered (8)
##   - ignored (1)
##   - scaled (8)
diabetes_train1 <- predict(pre_process, newdata = diabetes_train)
diabetes_test1 <- predict(pre_process, newdata = diabetes_test)
summary(diabetes_train1)
##     pregnant          glucose           pressure          triceps       
##  Min.   :-1.1728   Min.   :-3.6839   Min.   :-3.6238   Min.   :-1.3230  
##  1st Qu.:-0.8730   1st Qu.:-0.6835   1st Qu.:-0.3564   1st Qu.:-1.3230  
##  Median :-0.2736   Median :-0.1109   Median : 0.1178   Median : 0.1326  
##  Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.6257   3rd Qu.: 0.5610   3rd Qu.: 0.5921   3rd Qu.: 0.7654  
##  Max.   : 3.9228   Max.   : 2.3933   Max.   : 2.1731   Max.   : 4.9424  
##     insulin             mass             pedigree            age         
##  Min.   :-0.7124   Min.   :-4.04347   Min.   :-1.2063   Min.   :-1.0326  
##  1st Qu.:-0.7124   1st Qu.:-0.62327   1st Qu.:-0.7150   1st Qu.:-0.7794  
##  Median :-0.3250   Median : 0.07479   Median :-0.2770   Median :-0.3575  
##  Mean   : 0.0000   Mean   : 0.00000   Mean   : 0.0000   Mean   : 0.0000  
##  3rd Qu.: 0.4068   3rd Qu.: 0.54336   3rd Qu.: 0.4528   3rd Qu.: 0.5708  
##  Max.   : 6.5711   Max.   : 3.26231   Max.   : 5.6342   Max.   : 4.0307  
##  diabetes 
##  neg:350  
##  pos:188  
##           
##           
##           
## 
# New Model Using Standardized Dataset
model_knn1 <- train(diabetes ~ ., data = diabetes_train1, method = "knn")
predict_knn1 <- predict(model_knn1, newdata = diabetes_test1)

confusionMatrix(predict_knn1, diabetes_test1$diabetes, positive = "pos")
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction neg pos
##        neg 125  34
##        pos  25  46
##                                           
##                Accuracy : 0.7435          
##                  95% CI : (0.6819, 0.7986)
##     No Information Rate : 0.6522          
##     P-Value [Acc > NIR] : 0.001872        
##                                           
##                   Kappa : 0.4193          
##                                           
##  Mcnemar's Test P-Value : 0.297638        
##                                           
##             Sensitivity : 0.5750          
##             Specificity : 0.8333          
##          Pos Pred Value : 0.6479          
##          Neg Pred Value : 0.7862          
##              Prevalence : 0.3478          
##          Detection Rate : 0.2000          
##    Detection Prevalence : 0.3087          
##       Balanced Accuracy : 0.7042          
##                                           
##        'Positive' Class : pos             
## 
# Tune the KNN Model
model_knn2 <- train(diabetes ~ ., data = diabetes_train1, method = "knn",
                    tuneGrid = data.frame(k = seq(1, 25)),
                    trControl = trainControl(method = "repeatedcv", 
                                             number = 10, repeats = 3)) 
print(model_knn2)
## k-Nearest Neighbors 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## No pre-processing
## Resampling: Cross-Validated (10 fold, repeated 3 times) 
## Summary of sample sizes: 484, 484, 485, 484, 484, 485, ... 
## Resampling results across tuning parameters:
## 
##   k   Accuracy   Kappa    
##    1  0.7100163  0.3481778
##    2  0.7057536  0.3369634
##    3  0.7279874  0.3779726
##    4  0.7126136  0.3394666
##    5  0.7224552  0.3626817
##    6  0.7249126  0.3686210
##    7  0.7292919  0.3813656
##    8  0.7285698  0.3801563
##    9  0.7292220  0.3770692
##   10  0.7267296  0.3686163
##   11  0.7348008  0.3812809
##   12  0.7391684  0.3874511
##   13  0.7441067  0.3958417
##   14  0.7441300  0.3938309
##   15  0.7521663  0.4129465
##   16  0.7447473  0.3956097
##   17  0.7484160  0.4037529
##   18  0.7521430  0.4131625
##   19  0.7534125  0.4140869
##   20  0.7602259  0.4288439
##   21  0.7577918  0.4225572
##   22  0.7602492  0.4282741
##   23  0.7670510  0.4437613
##   24  0.7627067  0.4325283
##   25  0.7595970  0.4241233
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was k = 23.
plot(model_knn2)

# Bagging: Training
model_bag <- train(diabetes ~ ., data = diabetes_train1, method = "treebag")
model_bag
## Bagged CART 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## No pre-processing
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 538, 538, 538, 538, 538, 538, ... 
## Resampling results:
## 
##   Accuracy  Kappa    
##   0.764382  0.4616738
# Bagging: Prediction and Performance Evaluation
predict_bag <- predict(model_bag, newdata = diabetes_test1)
confusionMatrix(predict_bag, diabetes_test1$diabetes)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction neg pos
##        neg 123  39
##        pos  27  41
##                                           
##                Accuracy : 0.713           
##                  95% CI : (0.6499, 0.7706)
##     No Information Rate : 0.6522          
##     P-Value [Acc > NIR] : 0.02944         
##                                           
##                   Kappa : 0.3446          
##                                           
##  Mcnemar's Test P-Value : 0.17573         
##                                           
##             Sensitivity : 0.8200          
##             Specificity : 0.5125          
##          Pos Pred Value : 0.7593          
##          Neg Pred Value : 0.6029          
##              Prevalence : 0.6522          
##          Detection Rate : 0.5348          
##    Detection Prevalence : 0.7043          
##       Balanced Accuracy : 0.6663          
##                                           
##        'Positive' Class : neg             
## 
# Random Forest
library(randomForest)
## Warning: package 'randomForest' was built under R version 3.6.1
## randomForest 4.6-14
## Type rfNews() to see new features/changes/bug fixes.
## 
## Attaching package: 'randomForest'
## The following object is masked from 'package:ggplot2':
## 
##     margin
model_rf <- train(diabetes ~ ., data = diabetes_train1, method = "rf")
model_rf
## Random Forest 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## No pre-processing
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 538, 538, 538, 538, 538, 538, ... 
## Resampling results across tuning parameters:
## 
##   mtry  Accuracy   Kappa    
##   2     0.7706330  0.4735851
##   5     0.7726035  0.4823341
##   8     0.7646414  0.4646562
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was mtry = 5.
# Check the Importance of Attributes
varimp_rf <- varImp(model_rf)
varimp_rf
## rf variable importance
## 
##          Overall
## glucose  100.000
## mass      44.106
## pedigree  26.034
## age       21.980
## pressure   7.420
## pregnant   4.560
## triceps    1.229
## insulin    0.000
# Visualize the Attributes' Importance
plot(varimp_rf, main = "Variable Importance with Random Forest")

# Demo: Train a Linear SVM Model
library(kernlab)
## 
## Attaching package: 'kernlab'
## The following object is masked from 'package:ggplot2':
## 
##     alpha
model_svm_linear <- train(diabetes ~ ., data = diabetes_train,
                          method = "svmLinear",
                          preProcess = c("center", "scale"),
                          trControl = trainControl(method = "boot", number = 25),
                          tuneGrid = expand.grid(C = seq(0, 1, 0.05)))
## Warning: model fit failed for Resample01: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: C=0.00 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info =
## trainInfo, : There were missing values in resampled performance measures.
## Warning in train.default(x, y, weights = w, ...): missing values found in
## aggregated results
model_svm_linear
## Support Vector Machines with Linear Kernel 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## Pre-processing: centered (8), scaled (8) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 538, 538, 538, 538, 538, 538, ... 
## Resampling results across tuning parameters:
## 
##   C     Accuracy   Kappa    
##   0.00        NaN        NaN
##   0.05  0.7804531  0.4871273
##   0.10  0.7811148  0.4911283
##   0.15  0.7813750  0.4925428
##   0.20  0.7815711  0.4936755
##   0.25  0.7807481  0.4923266
##   0.30  0.7798998  0.4903754
##   0.35  0.7801015  0.4913055
##   0.40  0.7819002  0.4958506
##   0.45  0.7818835  0.4957785
##   0.50  0.7816940  0.4957656
##   0.55  0.7814910  0.4951923
##   0.60  0.7821010  0.4967286
##   0.65  0.7823040  0.4971134
##   0.70  0.7823040  0.4971134
##   0.75  0.7821049  0.4967044
##   0.80  0.7819049  0.4963103
##   0.85  0.7813163  0.4950101
##   0.90  0.7819019  0.4964707
##   0.95  0.7817086  0.4959279
##   1.00  0.7815086  0.4953690
## 
## Accuracy was used to select the optimal model using the largest value.
## The final value used for the model was C = 0.65.
# Sensitivity Test for C
plot(model_svm_linear)

# Linear SVM Performance Evaluation: Hold-out Method
predict_svm_linear <- predict(model_svm_linear, newdata = diabetes_test)
confusionMatrix(predict_svm_linear, diabetes_test$diabetes)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction neg pos
##        neg 126  36
##        pos  24  44
##                                           
##                Accuracy : 0.7391          
##                  95% CI : (0.6773, 0.7946)
##     No Information Rate : 0.6522          
##     P-Value [Acc > NIR] : 0.002949        
##                                           
##                   Kappa : 0.4041          
##                                           
##  Mcnemar's Test P-Value : 0.155580        
##                                           
##             Sensitivity : 0.8400          
##             Specificity : 0.5500          
##          Pos Pred Value : 0.7778          
##          Neg Pred Value : 0.6471          
##              Prevalence : 0.6522          
##          Detection Rate : 0.5478          
##    Detection Prevalence : 0.7043          
##       Balanced Accuracy : 0.6950          
##                                           
##        'Positive' Class : neg             
## 
# SVM with Non-linear Kernel: RBF
model_svm_rbf <- train(diabetes ~ ., data = diabetes_train,
                       preProcess = c("center", "scale"),
                       tuneGrid = expand.grid(sigma = seq(0, 1, 0.1),
                                              C = seq(0, 1, 0.1)),
                       method = "svmRadial",
                       trControl = trainControl(method = "boot",
                                                number = 25))
## Warning: model fit failed for Resample01: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample01: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample02: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample03: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample04: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample05: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample06: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample07: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample08: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample09: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample10: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample11: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample12: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample13: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample14: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample15: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample16: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample17: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample18: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample19: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample20: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample21: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample22: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample23: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample24: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.1, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.2, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.3, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.4, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.5, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.6, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.7, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.8, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=0.9, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning: model fit failed for Resample25: sigma=1.0, C=0.0 Error in .local(x, ...) : 
##   No Support Vectors found. You may want to change your parameters
## Warning in nominalTrainWorkflow(x = x, y = y, wts = weights, info =
## trainInfo, : There were missing values in resampled performance measures.
## Warning in train.default(x, y, weights = w, ...): missing values found in
## aggregated results
model_svm_rbf
## Support Vector Machines with Radial Basis Function Kernel 
## 
## 538 samples
##   8 predictor
##   2 classes: 'neg', 'pos' 
## 
## Pre-processing: centered (8), scaled (8) 
## Resampling: Bootstrapped (25 reps) 
## Summary of sample sizes: 538, 538, 538, 538, 538, 538, ... 
## Resampling results across tuning parameters:
## 
##   sigma  C    Accuracy   Kappa      
##   0.0    0.0        NaN          NaN
##   0.0    0.1  0.6493967  0.000000000
##   0.0    0.2  0.6493967  0.000000000
##   0.0    0.3  0.6493967  0.000000000
##   0.0    0.4  0.6493967  0.000000000
##   0.0    0.5  0.6493967  0.000000000
##   0.0    0.6  0.6493967  0.000000000
##   0.0    0.7  0.6493967  0.000000000
##   0.0    0.8  0.6493967  0.000000000
##   0.0    0.9  0.6493967  0.000000000
##   0.0    1.0  0.6493967  0.000000000
##   0.1    0.0        NaN          NaN
##   0.1    0.1  0.7508376  0.392957947
##   0.1    0.2  0.7663358  0.454691092
##   0.1    0.3  0.7683226  0.463308393
##   0.1    0.4  0.7671008  0.462373650
##   0.1    0.5  0.7658817  0.460458678
##   0.1    0.6  0.7634546  0.455447536
##   0.1    0.7  0.7606413  0.449869821
##   0.1    0.8  0.7578617  0.444340368
##   0.1    0.9  0.7566153  0.442762441
##   0.1    1.0  0.7558065  0.441046668
##   0.2    0.0        NaN          NaN
##   0.2    0.1  0.7139293  0.265026606
##   0.2    0.2  0.7462317  0.397978689
##   0.2    0.3  0.7488802  0.414221116
##   0.2    0.4  0.7459585  0.411941055
##   0.2    0.5  0.7449204  0.412423433
##   0.2    0.6  0.7447465  0.414660650
##   0.2    0.7  0.7437702  0.413067906
##   0.2    0.8  0.7415772  0.409046019
##   0.2    0.9  0.7431899  0.414238993
##   0.2    1.0  0.7413198  0.410656168
##   0.3    0.0        NaN          NaN
##   0.3    0.1  0.6728697  0.098551502
##   0.3    0.2  0.7261106  0.327888738
##   0.3    0.3  0.7333305  0.369330457
##   0.3    0.4  0.7346129  0.382005552
##   0.3    0.5  0.7353963  0.389783397
##   0.3    0.6  0.7325696  0.385775987
##   0.3    0.7  0.7297049  0.382456328
##   0.3    0.8  0.7308350  0.387367590
##   0.3    0.9  0.7302965  0.389178433
##   0.3    1.0  0.7286655  0.386092146
##   0.4    0.0        NaN          NaN
##   0.4    0.1  0.6498428  0.004327479
##   0.4    0.2  0.6923216  0.206349350
##   0.4    0.3  0.7181884  0.317645816
##   0.4    0.4  0.7259214  0.354318645
##   0.4    0.5  0.7272183  0.365525783
##   0.4    0.6  0.7237641  0.363646231
##   0.4    0.7  0.7233464  0.367703264
##   0.4    0.8  0.7231207  0.368261672
##   0.4    0.9  0.7246084  0.373541129
##   0.4    1.0  0.7233425  0.372424099
##   0.5    0.0        NaN          NaN
##   0.5    0.1  0.6493967  0.000000000
##   0.5    0.2  0.6711388  0.109932284
##   0.5    0.3  0.6985853  0.244242870
##   0.5    0.4  0.7092521  0.300215870
##   0.5    0.5  0.7157882  0.329586032
##   0.5    0.6  0.7193926  0.347022036
##   0.5    0.7  0.7168155  0.345105051
##   0.5    0.8  0.7188806  0.354193335
##   0.5    0.9  0.7183561  0.356666241
##   0.5    1.0  0.7195052  0.361500266
##   0.6    0.0        NaN          NaN
##   0.6    0.1  0.6493967  0.000000000
##   0.6    0.2  0.6565866  0.040656055
##   0.6    0.3  0.6807960  0.165222409
##   0.6    0.4  0.6925334  0.236565408
##   0.6    0.5  0.7063588  0.292976804
##   0.6    0.6  0.7098130  0.312262431
##   0.6    0.7  0.7125338  0.325172251
##   0.6    0.8  0.7142021  0.333692796
##   0.6    0.9  0.7150019  0.340241612
##   0.6    1.0  0.7148606  0.343869609
##   0.7    0.0        NaN          NaN
##   0.7    0.1  0.6493967  0.000000000
##   0.7    0.2  0.6503054  0.008608335
##   0.7    0.3  0.6629137  0.087346404
##   0.7    0.4  0.6821926  0.183709877
##   0.7    0.5  0.6908539  0.233769365
##   0.7    0.6  0.6999160  0.273591560
##   0.7    0.7  0.7051154  0.295927564
##   0.7    0.8  0.7074124  0.308398027
##   0.7    0.9  0.7102095  0.321069038
##   0.7    1.0  0.7127766  0.330863784
##   0.8    0.0        NaN          NaN
##   0.8    0.1  0.6493967  0.000000000
##   0.8    0.2  0.6500247  0.003771930
##   0.8    0.3  0.6544897  0.045247484
##   0.8    0.4  0.6667376  0.118380084
##   0.8    0.5  0.6778210  0.178806903
##   0.8    0.6  0.6830653  0.209998136
##   0.8    0.7  0.6929789  0.248820014
##   0.8    0.8  0.6988917  0.271646427
##   0.8    0.9  0.7005277  0.285014679
##   0.8    1.0  0.7031259  0.297305557
##   0.9    0.0        NaN          NaN
##   0.9    0.1  0.6493967  0.000000000
##   0.9    0.2  0.6496169  0.001076450
##   0.9    0.3  0.6487066  0.013910186
##   0.9    0.4  0.6588068  0.075000370
##   0.9    0.5  0.6696616  0.135242424
##   0.9    0.6  0.6723429  0.162154764
##   0.9    0.7  0.6766531  0.186161493
##   0.9    0.8  0.6839812  0.218127309
##   0.9    0.9  0.6880459  0.237481709
##   0.9    1.0  0.6911318  0.254394519
##   1.0    0.0        NaN          NaN
##   1.0    0.1  0.6493967  0.000000000
##   1.0    0.2  0.6498139  0.001468277
##   1.0    0.3  0.6484576  0.006624864
##   1.0    0.4  0.6537664  0.044170774
##   1.0    0.5  0.6601294  0.090566997
##   1.0    0.6  0.6651957  0.125408504
##   1.0    0.7  0.6699928  0.149860503
##   1.0    0.8  0.6745812  0.173752508
##   1.0    0.9  0.6760916  0.188456405
##   1.0    1.0  0.6817006  0.214383433
## 
## Accuracy was used to select the optimal model using the largest value.
## The final values used for the model were sigma = 0.1 and C = 0.3.
plot(model_svm_rbf)

predict_svm_rbf <- predict(model_svm_rbf, newdata = diabetes_test)
confusionMatrix(predict_svm_rbf, diabetes_test$diabetes)
## Confusion Matrix and Statistics
## 
##           Reference
## Prediction neg pos
##        neg 133  46
##        pos  17  34
##                                           
##                Accuracy : 0.7261          
##                  95% CI : (0.6636, 0.7826)
##     No Information Rate : 0.6522          
##     P-Value [Acc > NIR] : 0.0101891       
##                                           
##                   Kappa : 0.3405          
##                                           
##  Mcnemar's Test P-Value : 0.0004192       
##                                           
##             Sensitivity : 0.8867          
##             Specificity : 0.4250          
##          Pos Pred Value : 0.7430          
##          Neg Pred Value : 0.6667          
##              Prevalence : 0.6522          
##          Detection Rate : 0.5783          
##    Detection Prevalence : 0.7783          
##       Balanced Accuracy : 0.6558          
##                                           
##        'Positive' Class : neg             
## 
# Compare the Performance of Multiple Algorithms
model_comparison <- resamples(list(RF = model_rf, BAG = model_bag, SVMLinear = model_svm_linear,
                                   SVMRBF = model_svm_rbf, KNN = model_knn))
summary(model_comparison)
## 
## Call:
## summary.resamples(object = model_comparison)
## 
## Models: RF, BAG, SVMLinear, SVMRBF, KNN 
## Number of resamples: 25 
## 
## Accuracy 
##                Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## RF        0.7382199 0.7611940 0.7708333 0.7726035 0.7878788 0.8181818    0
## BAG       0.6969697 0.7463415 0.7669903 0.7643820 0.7878788 0.8050000    0
## SVMLinear 0.7330097 0.7720207 0.7868020 0.7823040 0.7990431 0.8191489    0
## SVMRBF    0.7437186 0.7527473 0.7658537 0.7683226 0.7801047 0.8106796    0
## KNN       0.6683417 0.6989796 0.7198068 0.7201809 0.7462687 0.7703349    0
## 
## Kappa 
##                Min.   1st Qu.    Median      Mean   3rd Qu.      Max. NA's
## RF        0.4044665 0.4478360 0.4717719 0.4823341 0.5147160 0.5827905    0
## BAG       0.3336874 0.4195252 0.4743661 0.4616738 0.5117076 0.5621913    0
## SVMLinear 0.3801291 0.4801290 0.5072536 0.4971134 0.5330089 0.5890382    0
## SVMRBF    0.3640898 0.4321016 0.4648102 0.4633084 0.5040366 0.5549030    0
## KNN       0.2400185 0.3103058 0.3559812 0.3631783 0.4071051 0.4687566    0
# Graphically Compare Performance
scales <- list(x = list(relation = "free"),
               y = list(relation = "free"))

bwplot(model_comparison, scales = scales)