createObjective(TunePareto)
createObjective()所属R语言包:TunePareto
Create a new objective function
创建一个新的目标函数
译者:生物统计家园网 机器人LoveR
描述----------Description----------
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.
创建一个新的TuneParetoObjective对象。一个客观的由两部分组成:预先计算函数,适用的数据的分类,和目标本身,这是计算出的预测类标签。
用法----------Usage----------
createObjective(precalculationFunction,
precalculationParams = NULL,
objectiveFunction,
objectiveFunctionParams = NULL,
direction = c("minimize", "maximize"),
name)
参数----------Arguments----------
参数:precalculationFunction
The name of the precalculation function that applies the classifiers to the data. Two predefined precalculation functions are reclassification and crossValidation.
预先计算函数,适用于分类器的数据的名称。两个预定义的预先计算功能是reclassification和crossValidation。
参数: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.
一个可读的名字的目的。
Details
详细信息----------Details----------
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 cross-validation (with the same parameters) are required, the cross-validation 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.
一个向量的样品中data类的标签。
A TuneParetoClassifier wrapper object containing the classifier to tune. A number of state-of-the-art classifiers are included in TunePareto (see predefinedClassifiers). Custom classifiers can be employed using tuneParetoClassifier.
ATuneParetoClassifier包装对象,它包含的分类调整。许多国家的艺术分类都包含在TunePareto(见predefinedClassifiers“)。自定义分类,可以采用使用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.
此外,该函数可以有更多的参数,提供precalculationParams。要训练一个分类器,并获得预测,预先计算函数可以调用的通用trainTuneParetoClassifier和predict.TuneParetoModel函数。
The precalculation function usually returns the predicted labels and the true labels, 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.
预先计算的函数通常返回的预测的标签和真正的标签,但返回值的唯一要求是,它可以处理由相应的目标函数。预定义的预先计算功能是reclassification和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 returns a number specifying the objective value.
目标函数具有一个单一的必的参数名为result供给的预先计算的结果。此外,可选的参数可以被指定。它们的值从objectiveFunctionParams。该函数返回一个指定的目标函数值的数量。
值----------Value----------
Retuns an object of class TuneParetoObjective with the following components:
Retuns对象类TuneParetoObjective有以下组件:
参数:precalculationFunction
The supplied precalculation function
所提供的预先计算功能
参数:precalculationParams
The additional parameters to be passed to the precalculation function
要传递给预先计算函数的附加参数
参数:objectiveFunction
The objective function
目标函数
参数:minimize
TRUE if the objective is minimized, FALSE if it is maximized.
TRUE,如果目标是最小化,FALSE,如果它是最大化。
参数:name
The readable name of the objective.
的目标,可读的名称。
参见----------See Also----------
predefinedObjectiveFunctions, trainTuneParetoClassifier, predict.TuneParetoModel
predefinedObjectiveFunctions,trainTuneParetoClassifier,predict.TuneParetoModel
实例----------Examples----------
# create new objective minimizing the[创建新的目标,最大限度地减少]
# false positives of a reclassification[误报重新分类]
cvFalsePositives <- function(nfold=10, ntimes=10, leaveOneOut=FALSE, foldList=NULL, caseClass)
{
return(createObjective(
precalculationFunction = "crossValidation",
precalculationParams = list(nfold=nfold,
ntimes=ntimes,
leaveOneOut=leaveOneOut,
foldList=foldList),
objectiveFunction =
function(result, caseClass)
{
# take mean value over the cv runs[取平均值的CV运行]
return(mean(sapply(result,
function(run)
# iterate over runs of cross-validation[迭代运行的交叉验证]
{
# extract all predicted labels in the folds[提取的褶皱所有预测的标签]
predictedLabels <-
unlist(lapply(run,
function(fold)fold$predictedLabels))
# extract all true labels in the folds[提取的褶皱所有真正的标签]
trueLabels <-
unlist(lapply(run,
function(fold)fold$trueLabels))
# calculate number of false positives in the run[计算在运行误报数量]
return(sum(predictedLabels == caseClass &
trueLabels != caseClass))
})))
},
objectiveFunctionParams = list(caseClass=caseClass),
direction = "minimize",
name = "CV.FalsePositives"))
}
# use the objective in an SVM cost parameter tuning on the 'iris' data set[IRIS数据集,使用成本的SVM参数整定的目标]
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(cvFalsePositives(10, 10, caseClass="setosa")))
print(r)
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|