whylogs.core.metrics.confusion_matrix
¶
Module Contents¶
Classes¶
Confusion Matrix Class to hold labels and matrix data. |
Functions¶
|
Merges two confusion_matrix since distinc or overlaping labels |
Attributes¶
- whylogs.core.metrics.confusion_matrix.SUPPORTED_TYPES = ['binary', 'multiclass']¶
- whylogs.core.metrics.confusion_matrix.MODEL_METRICS_MAX_LABELS = 256¶
- whylogs.core.metrics.confusion_matrix.MODEL_METRICS_LABEL_SIZE_WARNING_THRESHOLD = 64¶
- whylogs.core.metrics.confusion_matrix._logger¶
- class whylogs.core.metrics.confusion_matrix.ConfusionMatrix(labels: List[str] = None, prediction_field: str = None, target_field: str = None, score_field: str = None)¶
Confusion Matrix Class to hold labels and matrix data.
- labels¶
list of labels in a sorted order
- prediction_field¶
name of the prediction field
- target_field¶
name of the target field
- score_field¶
name of the score field
- confusion_matrix¶
Confusion Matrix kept as matrix of NumberTrackers
- Type
nd.array
- labels¶
list of labels for the confusion_matrix axes
- Type
List[str]
- add(self, predictions: List[Union[str, int, bool]], targets: List[Union[str, int, bool]], scores: List[float])¶
Function adds predictions and targets to confusion matrix with scores.
- Parameters
predictions (List[Union[str, int, bool]]) –
targets (List[Union[str, int, bool]]) –
scores (List[float]) –
- Raises
NotImplementedError – in case targets do not fall into binary or
multiclass suport –
ValueError – incase missing validation or predictions
- merge(self, other_cm)¶
Merge two seperate confusion matrix which may or may not overlap in labels.
- Parameters
other_cm (Optional[ConfusionMatrix]) – confusion_matrix to merge with self
- Returns
merged confusion_matrix
- Return type
- to_protobuf(self)¶
Convert to protobuf
- Returns
Description
- Return type
TYPE
- classmethod from_protobuf(cls, message: whylogs.proto.ScoreMatrixMessage)¶
- whylogs.core.metrics.confusion_matrix._merge_CM(old_conf_matrix: ConfusionMatrix, new_conf_matrix: ConfusionMatrix)¶
Merges two confusion_matrix since distinc or overlaping labels
- Parameters
old_conf_matrix (ConfusionMatrix) –
new_conf_matrix (ConfusionMatrix) – Will be overridden