fatf.utils.metrics.tools
.validate_confusion_matrix¶
-
fatf.utils.metrics.tools.
validate_confusion_matrix
(confusion_matrix: numpy.ndarray, label_index: Optional[int] = None) → bool[source]¶ Validates a confusion matrix.
This function checks whether the
confusion_matrix
is 2-dimensional, square, unstructured and of integer kind.If the
label_index
parameter is given, it is checked to be a valid index for the given confusion matrix.- Parameters
- confusion_matrixnumpy.ndarray
A confusion matrix to be validated.
- label_indexinteger, optional (default=None)
An index which validity will be checked for the confusion matrix (if not
None
).
- Returns
- is_validboolean
True
if the confusion matrix is valid,False
otherwise.
- Raises
- IncorrectShapeError
The confusion matrix is not a 2-dimensional numpy array, it is not square (equal width and height) or its dimension is not at least 2x2.
- IndexError
The
label_index
(if given) is not valid for the confusion matrix.- TypeError
The confusion matrix is not of an integer kind (e.g.
int
,numpy.int32
,numpy.int64
). Thelabel_index
is not an integer.- ValueError
The confusion matrix is a structured numpy array.