Confusionmatrix: Difference between revisions
imported>Donal (Created page with "===Purpose=== Create confusion matrix from a classification model or from a list of actual classes and a list of predicted classes. ===Synopsis=== :[misclassed, classids, tex...") |
imported>Donal No edit summary |
||
Line 1: | Line 1: | ||
===Purpose=== | ===Purpose=== | ||
Create confusion matrix from a classification model or from a list of actual classes and a list of predicted classes. | Create a confusion matrix showing classification rates from a classification model or from a list of actual classes and a list of predicted classes. | ||
Line 39: | Line 39: | ||
* '''misclassed''' = confusion matrix, nclasses x 4 array, one row per class, columns are True/False Postive/Negative rates (TP FP TN FN), | * '''misclassed''' = confusion matrix, nclasses x 4 array, one row per class, columns are True/False Postive/Negative rates (TP FP TN FN), | ||
* '''classids''' = class names (identifiers), | * '''classids''' = class names (identifiers), | ||
* '''texttable''' = cell array containing a text representation of the confusion matrix, 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. | * '''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 confusionmatrix with no output variables assigned: | |||
'confusionmatrix(model)' | |||
displays the output: | |||
>> confusionmatrix(model) | |||
Confusion Matrix: | |||
Class: TP FP TN FN | |||
K 1.00000 0.03774 0.96226 0.00000 | |||
BL 0.77778 0.00000 1.00000 0.22222 | |||
SH 1.00000 0.00000 1.00000 0.00000 | |||
AN 1.00000 0.00000 1.00000 0.00000 | |||
===See Also=== | ===See Also=== | ||
[[confusiontable]], [[plsda]], [[svmda]], [[knn]], [[simca]] | [[confusiontable]], [[plsda]], [[svmda]], [[knn]], [[simca]] |
Revision as of 16:02, 19 September 2011
Purpose
Create a confusion matrix showing classification rates from a classification model or from a list of actual classes and a list of predicted classes.
Synopsis
- [misclassed, classids, texttable] = confusionmatrix(model); % create confusion matrix from classifier model
- [misclassed, classids, texttable] = confusionmatrix(model, usecv); % create confusion matrix from model using CV results
- [misclassed, classids, texttable] = confusionmatrix(trueClass, predClass); % create confusion matrix from vectors of true and pred classes
Description
Confusionmatrix creates a table of results showing True Positive, False Postive, True Negative and False Negative rates (TP FP TN FN) as a matrix for each class modeled in an input model. Input models must be of type PLSDA, SVMDA, KNN, or SIMCA.
Optional second parameter "usecv" specifies use of the cross-validation based "cvmisclassification" instead of the default self-prediction classifications.
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
- 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
- misclassed = confusion matrix, nclasses x 4 array, one row per class, columns are True/False Postive/Negative rates (TP FP TN FN),
- 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 confusionmatrix with no output variables assigned: 'confusionmatrix(model)' displays the output:
>> confusionmatrix(model) Confusion Matrix: Class: TP FP TN FN K 1.00000 0.03774 0.96226 0.00000 BL 0.77778 0.00000 1.00000 0.22222 SH 1.00000 0.00000 1.00000 0.00000 AN 1.00000 0.00000 1.00000 0.00000
See Also
confusiontable, plsda, svmda, knn, simca