Description Usage Arguments Details Value See Also Examples
Creates a new TuneParetoObjective
object. An objective consists of two parts: The precalculation function, which applies the classifier to the data, and the objective itself, which is calculated from the predicted class labels.
1 2 3 4 5 6  createObjective(precalculationFunction,
precalculationParams = NULL,
objectiveFunction,
objectiveFunctionParams = NULL,
direction = c("minimize", "maximize"),
name)

precalculationFunction 
The name of the precalculation function that applies the classifiers to the data. Two predefined precalculation functions are 
precalculationParams 
A named list of parameters for the precalculation function. 
objectiveFunction 
The name of the objective function that calculates the objective from the precalculated class labels. 
objectiveFunctionParams 
A named list of further parameters for the objective function. 
direction 
Specifies whether the objective is minimized or maximized. 
name 
A readable name of the objective. 
The objective calculation is divided into a precalculation step and the objective calculation itself. The main reason for this is the possibility to aggregate precalculation across objectives. For example, if both the specificity and the sensitivity of a crossvalidation (with the same parameters) are required, the crossvalidation is run only once to save computational time. Afterwards, the results are passed to both objective functions.
A precalculation function has the following parameters:
The data set to be used for the precalculation. This is usually a matrix or data frame with the samples in the rows and the features in the columns.
A vector of class labels for the samples in data
.
A TuneParetoClassifier
wrapper object containing the classifier to tune. A number of stateoftheart classifiers are included in TunePareto (see predefinedClassifiers
). Custom classifiers can be employed using tuneParetoClassifier
.
A named list of parameter assignments for the classifier.
If the classifier has separate training and prediction functions, a named list of parameter assignments for the predictor.
Additionally, the function can have further parameters which are supplied in precalculationParams
. To train a classifier and obtain predictions, the precalculation function can call the generic trainTuneParetoClassifier
and predict.TuneParetoModel
functions.
The precalculation function usually returns the predicted labels, the true labels and the model, but the only requirement of the return value is that it can be processed by the corresponding objective function. Predefined precalculation functions are reclassification
and crossValidation
.
The objective function has a single obligatory parameter named result
which supplies the result of the precalculation. Furthermore, optional parameters can be specified. Their values are taken from objectiveFunctionParams
. The function either returns a single number specifying the objective value, or a list with a score
component containing the objective value and a additionalData
component that contains additional information to be stored in the additionalData
component of the TuneParetoResult
object (see tunePareto
).
Retuns an object of class TuneParetoObjective
with the following components:
precalculationFunction 
The supplied precalculation function 
precalculationParams 
The additional parameters to be passed to the precalculation function 
objectiveFunction 
The objective function 
minimize 

name 
The readable name of the objective. 
predefinedObjectiveFunctions
, trainTuneParetoClassifier
, predict.TuneParetoModel
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37  # create new objective minimizing the number of support vectors
# for a support vector machine
reclassSupportVectors < function (saveModel = FALSE)
{
createObjective(precalculationFunction = reclassification,
precalculationParams = NULL, objectiveFunction =
function(result, saveModel)
{
if(result$model$classifier$name != "svm")
stop("This objective function can only be applied
to classifiers of type tunePareto.svm()")
res < result$model$model$tot.nSV
if (saveModel)
# return a list containing the objective value as well as the model
{
return(list(additionalData = result$model, fitness = res))
}
else
# only return the objective value
return(res)
},
objectiveFunctionParams = list(saveModel = saveModel),
direction = "minimize",
name = "Reclass.SupportVectors")
}
# tune error vs. number of support vectors on the 'iris' data set
r < tunePareto(data = iris[, ncol(iris)],
labels = iris[, ncol(iris)],
classifier = tunePareto.svm(),
cost=c(0.001,0.005,0.01,0.05,0.1,0.5,1,5,10,50),
objectiveFunctions=list(reclassError(), reclassSupportVectors()))
print(r)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.