tuneParetoClassifier: Create a classifier object

View source: R/classifiers.R

tuneParetoClassifierR Documentation

Create a classifier object

Description

Creates a wrapper object mapping all information necessary to call a classifier which can be passed to tunePareto.

Usage

tuneParetoClassifier(name,
                     classifier, 
                     classifierParamNames = NULL, 
                     predefinedClassifierParams = NULL, 
                     predictor = NULL, 
                     predictorParamNames = NULL, 
                     predefinedPredictorParams = NULL, 
                     useFormula = FALSE, 
                     formulaName = "formula", 
                     trainDataName = "x", 
                     trainLabelName = "y", 
                     testDataName = "newdata", 
                     modelName = "object", 
                     requiredPackages = NULL)

Arguments

name

A human-readable name of the classifier

classifier

The classification function to use. If predictor is NULL, this function is an all-in-one classification method that receives both training data and test data and returns the predicted labels for the test data. If predictor is not NULL, this is the training function of the classifier that builds a model from the training data. This model is then passed to predictor along with the test data to obtain the predicted labels for the test data.

classifierParamNames

A vector of names of possible arguments for classifier.

predefinedClassifierParams

A named list of default values for the classifier parameters.

predictor

If the classification method consists of separate training and prediction functions, this points to the prediction function that receives a model and the test data as inputs and returns the predicted class labels.

predictorParamNames

If predictor != NULL, a vector of names of possible arguments for predictor.

predefinedPredictorParams

If predictor != NULL, a named list of default values for the parameters of predictor.

useFormula

Set this to true if the classifier expects a formula to describe the relation between features and class labels. The formula itself is built automatically.

formulaName

If useFormula is true, this is the name of the parameter of the classifier's training function that holds the formula.

trainDataName

The name of the paramater of the classifier's training function that holds the training data.

trainLabelName

If useFormula=FALSE, the name of the paramater of the classifier's training function that holds the training labels. Otherwise, the training labels are added to the training data and supplied in parameter trainDataName.

testDataName

If predictor=NULL, this is the name of the parameter of classifier that receives the test data. Otherwise, it is the parameter of predictor that holds the test data.

modelName

If predictor is not NULL, this is the name of the parameter of predictor that receives the training model (i.e., the return value of classifier).

requiredPackages

A vector containing the names of packages that are required to run the classifier. These packages are loaded automatically when running the classifier using tunePareto. They are also loaded in the snowfall cluster if necessary.

Details

TunePareto classifier objects are wrappers containing all information necessary to run the classifier, including the training and prediction function, the required packages, and the names of certain arguments. TunePareto provides a set of predefined objects for state-of-the-art classifiers (see predefinedClassifiers).

The main tunePareto routine evaluates TuneParetoClassifier objects to call the training and prediction methods. Furthermore, direct calls to the classifiers are possible using trainTuneParetoClassifier and predict.TuneParetoModel.

Value

An object of class TuneParetoClassifier with components corresponding to the above parameters.

See Also

trainTuneParetoClassifier, predict.TuneParetoModel, tunePareto, predefinedClassifiers

Examples

  # equivalent to tunePareto.svm()
  cl <- tuneParetoClassifier(name = "svm",
                             classifier = svm, 
                             predictor = predict, 
                             classifierParamNames = c("kernel", "degree", "gamma",
                                                      "coef0", "cost", "nu",
                                                      "class.weights", "cachesize", 
                                                      "tolerance", "epsilon",
                                                      "subset", "na.action"),
                              useFormula = FALSE,
                              trainDataName = "x",
                              trainLabelName = "y",
                              testDataName = "newdata",
                              modelName = "object",
                              requiredPackages="e1071")
  
  # call TunePareto with the classifier
  print(tunePareto(classifier = cl,
                   data = iris[, -ncol(iris)], 
                   labels = iris[, ncol(iris)],
                   cost = c(0.001,0.01,0.1,1,10), 
                   objectiveFunctions=
                     list(cvError(10, 10),
                          cvSpecificity(10, 10, 
                            caseClass="setosa"))))                           

TunePareto documentation built on Oct. 2, 2023, 5:06 p.m.