lau_confmatrix

 

USE:

[confmatrix, elperclass] = lau_confmatrix(t,y,opt)

 

DESCRIPTION:

Returns the confusion matrix for a classifier.

 

ARGUMENTS:

t is the vector of targets (true class) while y is the vector of predictions (predicted class). opt may be set to ‘c’ to obtain the confusion matrix normalized, so that the sum of elements on each row in 1. 

 

VALUES:

The confmatrix returned is a NcxNc matrix whose elements represent the number of cases in which the predicted class was the one given by the column index while the true class was the one given by the row index. If opt is not set to ’c’ each row is further divided by the number of samples in t which belong to the class specified by the row index. elperclass is the number of cases in t for each class.

 

EXAMPLES:

//load the iris data set. There are 3 classes and 50 samples in each

> irisdata

//use half of the iris data set as prototypes, for a 5-nearest neighbor, to classify the remaining half

>class=lau_knn(1,X(1:2:end,:),y(1:2:end),X(2:2:end,:))

//compute the confusion matrix

[confmatrix,elperclass] = lau_confmatrix(y(2:2:end),class,’c’)

//compute the normalized confusion matrix

[confmatrix,elperclass] = lau_confmatrix(y(2:2:end),class)

 

 

COMMENTS:

Created by Laurentiu Adi Tarca. Revised 10.07.2003

This help was created on 12.03.2004