Confusiontable: Difference between revisions

From Eigenvector Research Documentation Wiki
Jump to navigation Jump to search
imported>Donal
imported>Donal
Line 7: Line 7:
:[confusiontab, classids, texttable] = confusiontable(model);                % create confusion table from classifier model
:[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(model, usecv);        % create confusion table from model using CV results
:[confusiontab, classids, texttable] = confusiontable(model, usecv, predrule); % create confusion table from model specifying CV and predrule
:[confusiontab, classids, texttable] = confusiontable(trueClass, predClass); % create confusion table from vectors of true and pred classes
:[confusiontab, classids, texttable] = confusiontable(trueClass, predClass); % create confusion table from vectors of true and pred classes



Revision as of 14:01, 30 August 2017

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(model, usecv, predrule); % create confusion table from model specifying CV and predrule
[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. The 'most probable' predicted class is used when a model is input. 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 cross-validation results (assuming they are available in the model),
  • trueClass = vector of numeric values indicating the true sample classes,
  • predClass = vector of numeric values indicating the predicted sample classes.
  • predrule = the classification rule used. 'mostprobable' makes predictions based on choosing the class that has the highest probability. 'strict' makes predictions based on the rule that each sample belongs to a class if the probability is greater than a specified threshold probability value for one and only one class.

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 table. The 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 table 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