centroidcl | R Documentation |
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.
centroidcl(train, test, cl, cl.test = NULL)
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) |
centroidcl
carries out the centroid classifier and predicts classification.
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 |
Christian Hennig, Cinzia Viroli
See Also theta.cl
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.