centroidcl {quantileDA}R Documentation

A function that performs the centroid classifier

Description

Given a training and a test set, the function apply the centroid classifier and returns the classification labels of the observations in the training and in test set. It also gives the training misclassification rate and the test misclassification rate, if the truth class labels of the test set are provided in input.

Usage

centroidcl(train, test, cl, cl.test = NULL)

Arguments

train

A matrix of data (the training set) with observations in rows and variables in column. It can be a matrix or a dataframe.

test

A matrix of data (the test set) with observations in rows and variables in columns. It can be a matrix or a dataframe.

cl

A vector of class labels for each sample of the training set. It can be factor or numerical.

cl.test

A vector of class labels for each sample of the test set (optional)

Details

centroidcl carries out the centroid classifier and predicts classification.

Value

A list with components

cl.train

Predicted classification in the training set

cl.test

Predicted classification in the test set

me.train

Misclassification error in the training set

me.test

Misclassification error in the test set (only if cl.test is available)

Author(s)

Christian Hennig, Cinzia Viroli

See Also

See Also theta.cl

Examples

data(ais)
x=ais[,3:13]
cl=as.double(ais[,1])
set.seed(22)
index=sample(1:202,152,replace=FALSE)
train=x[index,]
test=x[-index,]
cl.train=cl[index]
cl.test=cl[-index]
out.c=centroidcl(train,test,cl.train,cl.test)
out.c$me.test
misc(out.c$cl.test,cl.test)

[Package quantileDA version 1.2 Index]