CVBpy 14.0
ConfusionMatrix Class Reference

Representation of a confusion matrix. More...

Inherits object.

Public Member Functions

List[cvb.polimago.PredictionResultat (self, int true_class, int predicted_class)
Access the results stored in the confusion matrix. More...

int rejects (self, int class_index)
Get the rejects for a given class. More...

int total_correct (self, Optional[int] class_index)
Determine the number of correctly classified samples (for a given class if class index is specified). More...

int total_errors (self, Optional[int] class_index)
Determine the number of errors (for a given class if class index is specified). More...

int total_rejects (self)
Total number of rejected items. More...

int total_samples (self, Optional[int] class_index)
Determine the total number of samples available (for a given class if class index is specified). More...

Properties

confidence_threshold = property
float: Threshold to be taken into account when determining the confusion matrix. More...

num_classes = property
int: Number of classes in this matrix.

Detailed Description

Representation of a confusion matrix.

Create representation of a confusion matrix.

A confusion matrix is a matrix that gives detailed information about the kind of mistakes that occurred during a leave-out or sample test.

Parameters

res : cvb.polimago.ClassificationTestResult ClassificationTestResult for which to calculate the confusion matrix.

◆ at()

 List[cvb.polimago.PredictionResult] at ( self, int true_class, int predicted_class )

Access the results stored in the confusion matrix.

The confusion matrix is to be read as follows: The first index (usually considered the line index) corresponds to the true class index, whereas the 2nd index (column index) is the prediction result. Example: Consider the result counts in a confusion matrix for a two-class problem to be distributed as follows: A B A 10 3 B 1 6 This means that 10 samples of class A have been correctly identified as class A, while 3 samples of class A have been misclassified as class B. Likewise, one sample of class B has been misclassified as class A, while 6 samples of class B have been identified correctly.

Parameters

true_class : int True class index.

predicted_class : int Prediction result.

Returns

List[cvb.polimago.PredictionResult] Confusion matrix value.

◆ rejects()

 int rejects ( self, int class_index )

Get the rejects for a given class.

Parameters

class_index : int Index of the class for which to retrieve the rejected results.

Returns

int The rejected results for given class.

◆ total_correct()

 int total_correct ( self, Optional[int] class_index )

Determine the number of correctly classified samples (for a given class if class index is specified).

Parameters

class_index : Optional[int] Index of the class for which to query the number of correct classifications.

Returns

int Number of correctly classified samples - for the class referred to by the class_index parameter, over all classes if index not specified.

◆ total_errors()

 int total_errors ( self, Optional[int] class_index )

Determine the number of errors (for a given class if class index is specified).

Parameters

class_index : Optional[int] Index of the class for which to query the number of incorrect results.

Returns

int Number of incorrect results - for the class referred to by the class_index parameter, over all classes if index not specified.

◆ total_rejects()

 int total_rejects ( self )

Total number of rejected items.

Items that have a confidence of less than the currently set threshold, no matter if they are correctly classified or not).

Returns

int Total number of rejects over all classes.

◆ total_samples()

 int total_samples ( self, Optional[int] class_index )

Determine the total number of samples available (for a given class if class index is specified).

Parameters

class_index : Optional[int] Index of the class for which to query the number of samples.

Returns

int Total number of samples - in the class referred to by the class_index parameter, over all classes if index not specified.

◆ confidence_threshold

 confidence_threshold = property
static

float: Threshold to be taken into account when determining the confusion matrix.

If the threshold is modified, the whole matrix will be updated accordingly, so setting this property may be a costly action.