Confusiontable: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Donal
imported>Donal
Line 20: Line 20:


Input can consist of vectors of true class and predicted class instead of a model.
Input can consist of vectors of true class and predicted class instead of a model.
Classification rates are defined as:
TP: proportion of positive cases that were correctly identified
FP: proportion of negatives cases that were incorrectly classified as positive
TN: proportion of negatives cases that were classified correctly
FN: proportion of positive cases that were incorrectly classified as negative


====Inputs====
====Inputs====

Revision as of 18:07, 19 September 2011

Purpose

Create a confusion table where entries show the number predicted to belong to 'i-th' class which actually belong to the 'j-th' class from an input classification model or from lists of actual classes and predicted classes.

Synopsis

[confusiontab, classids, texttable] = confusiontable(model);  % create confusion table from classifier model
[confusiontab, classids, texttable] = confusiontable(model, usecv);  % create confusion table from model using CV results
[confusiontab, classids, texttable] = confusiontable(trueClass, predClass); % create confusion table from vectors of true and pred classes

Description

Calculate confusion table for classification model or from a list of actual classes and a list of predicted classes. Create a table with entry (i,j) = number predicted to be class with index i which actually are class with index j. Input models must be of type PLSDA, SVMDA, KNN, or SIMCA.

Optional second parameter "usecv" specifies use of the cross-validation based "model.detail.cvmisclassification" instead of the default self-prediction classifications "model.classification".

Input can consist of vectors of true class and predicted class instead of a model.

Inputs

  • model = previously generated classifier model or pred structure,
  • usecv = 0 or 1. 0 indicates confusion matrix should be based on self-prediction results, 1 indicates it is based on using CV on calibration data,
  • trueClass = vector of numeric values indicating the true sample classes,
  • predClass = vector of numeric values indicating the predicted sample classes.

Outputs

  • confusiontab = confusion table, nclasses x nclasses array, where the (i,j) cell shows the number of samples which were predicted to be class i but which actually were class j.
  • classids = class names (identifiers),
  • texttable = cell array containing a text representation of the confusion matrix. Thi i-th element of the cell array, texttable{i}, is the i-th line of the texttable. Note that this text representation of the confusion matrix is displayed if the function is called with no output assignment.

Example

Calling confusiontable with no output variables assigned: 'confusiontable(model)' displays the output:

>> confusiontable(model)
Confusion Table:                                           
                                Actual Class              
                               K       BL       SH       AN
Predicted as          K        10        2        0        0
Predicted as         BL         0        7        0        0
Predicted as         SH         0        0       23        0
Predicted as         AN         0        0        0       21

See Also

confusionmatrix, plsda, svmda, knn, simca