svm_cv | R Documentation |
This function conduct k-fold Cross Validation for SVM.
svm_cv(
dataset,
label.col = 1,
positive.class = NULL,
folds.num = 10,
seed = 1,
parallel.cores = 2,
...
)
dataset |
The dataset obtained from function |
label.col |
integer specifying the column number of the label. (Default: |
positive.class |
Character. Indicate the positive class of the dataset.
(Default: |
folds.num |
Integer. Specify the number of folds for cross-validation.
(Default: |
seed |
Integer. Used to set the seed for cross-validation. (Default: |
parallel.cores |
Integer. The number of cores for parallel computation.
By default the number of cores is |
... |
additional parameters for function |
During the model tuning, the performance of each combination of parameters will output. Sensitivity, Specificity, Accuracy, F-Measure and Kappa Value are used to evaluate the performances. The best gamma and cost (or best model) are selected based on Accuracy.
For the details of parameter gamma and cost, please refer to function
svm
of package "e1071".
For the details of metrics, please refer to function
confusionMatrix
of package "caret".
Returns the optimal parameters when return.model = FALSE
.
Or returns the best model when return.model = TRUE
.
HAN Siyu
extract_features
, svm_tune
.
## Not run:
data(demo_dataset)
my_dataset <- demo_dataset
cv_res <- svm_cv(my_dataset, folds.num = 4, seed = 1,
parallel.core = 2, cost = 3, kernel = "radial", gamma = 0.5)
### Users can set return.model = TRUE to return the best model.
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.