View source on GitHub |
Multi-label confusion matrix.
Inherits From: Metric
tfma.metrics.MultiLabelConfusionMatrixPlot(
thresholds: Optional[List[float]] = None,
num_thresholds: Optional[int] = None,
name: str = MULTI_LABEL_CONFUSION_MATRIX_PLOT_NAME
)
For each actual class (positive label) a confusion matrix is computed for each class based on the associated predicted values such that:
TP = positive_prediction_class_label & positive_prediction TN = negative_prediction_class_label & negative_prediction FP = negative_prediction_class_label & positive_prediction FN = positive_prediction_class_label & negative_prediction
For example, given classes 0, 1 and a given threshold, the following matrices will be computed:
Actual: class_0 Predicted: class_0 TP = is_class_0 & is_class_0 & predict_class_0 TN = is_class_0 & not_class_0 & predict_not_class_0 FN = is_class_0 & is_class_0 & predict_not_class_0 FP = is_class_0 & not_class_0 & predict_class_0 Actual: class_0 Predicted: class_1 TP = is_class_0 & is_class_1 & predict_class_1 TN = is_class_0 & not_class_1 & predict_not_class_1 FN = is_class_0 & is_class_1 & predict_not_class_1 FP = is_class_0 & not_class_1 & predict_class_1 Actual: class_1 Predicted: class_0 TP = is_class_1 & is_class_0 & predict_class_0 TN = is_class_1 & not_class_0 & predict_not_class_0 FN = is_class_1 & is_class_0 & predict_not_class_0 FP = is_class_1 & not_class_0 & predict_class_0 Actual: class_1 Predicted: class_1 TP = is_class_1 & is_class_1 & predict_class_1 TN = is_class_1 & not_class_1 & predict_not_class_1 FN = is_class_1 & is_class_1 & predict_not_class_1 FP = is_class_1 & not_class_1 & predict_class_1
Note that unlike the multi-class confusion matrix, the inputs are assumed to be multi-label whereby the predictions may not necessarily sum to 1.0 and multiple classes can be true as the same time.
Methods
computations
computations(
eval_config: Optional[tfma.EvalConfig
] = None,
schema: Optional[schema_pb2.Schema] = None,
model_names: Optional[List[str]] = None,
output_names: Optional[List[str]] = None,
sub_keys: Optional[List[Optional[SubKey]]] = None,
aggregation_type: Optional[AggregationType] = None,
class_weights: Optional[Dict[int, float]] = None,
example_weighted: bool = False,
query_key: Optional[str] = None
) -> tfma.metrics.MetricComputations
Creates computations associated with metric.
from_config
@classmethod
from_config( config: Dict[str, Any] ) -> 'Metric'
get_config
get_config() -> Dict[str, Any]
Returns serializable config.