Learn R Programming

LedPred (version 1.6.0)

mcTune: Tuning the SVM parameters

Description

The mcTune function is a modified version of the function tune from package e1071 [6]. It tests the different combinations of C and gamma parameters given as vectors in a list and will return the prediction error computed during the cross-validation step.

Usage

mcTune(data, cl = 1, ranges = list(gamma = c(1, 10), cost = c(1, 10)), kernel = "linear", valid.times = 10, file.prefix = NULL, numcores = ifelse(.Platform$OS.type == "windows", 1, parallel::detectCores() - 1))

Arguments

data
data.frame containing the training set
cl
integer indicating the column number corresponding to the response vector that classify positive and negative regions (default = 1)
ranges
list object containing one (linear kernel) or two (radial kernel) vectors of integers corresponding to SVM cost and SVM gamma parameters to test.
kernel
SVM kernel, a character string: "linear" or "radial". (default = "radial")
valid.times
Integer indicating how many times the training set will be split for the cross validation step (default = 10). This number must be smaller than positive and negative sets sizes.
file.prefix
A character string that will be used as a prefix followed by "_c_g_eval.png" for result plot files, if it is NULL (default), no plot is returned
numcores
Number of cores to use for parallel computing (default: the number of available cores in the machine - 1)

Value

A list of class tune
best.parameters
A list of the parameters giving the lowest misclassification error
best.performance
The lowest misclassification error
method
The method used
nparcomb
the number of tested parameter combinations
train.ind
The indexes used to produce subsets during the cross validation step
sampling
The cross-validation fold number
performances
A matrix summarizing the cross-validation step with the error for each tested parameter at each round and the dispersion of these errors (regarding to the average error)
best.model
The model produced by the best parameters

Examples

Run this code
data(crm.features)
cost.vector <- c(1,3,10,30)
gamma.vector <- c(1,3,10,30)
#c.g.obj <- mcTune(data.granges= crm.features, ranges = list(cost=cost.vector,
#    gamma=gamma.vector), kernel='linear', file.prefix = "test")
#names(c.g.obj)
# cost <- c.g.obj$best.parameters$cost
# gamma <- c.g.obj$best.parameters$gamma

Run the code above in your browser using DataLab