tfma.metrics.MultiLabelConfusionMatrixPlot

View source on GitHub

Multi-label confusion matrix.

Inherits From: Metric

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.

thresholds Optional thresholds. Only one of either thresholds or num_thresholds should be used. If both are unset, then [0.5] will be assumed.
num_thresholds Number of thresholds to use. The thresholds will be evenly spaced between 0.0 and 1.0 and inclusive of the boundaries (i.e. to configure the thresholds to [0.0, 0.25, 0.5, 0.75, 1.0], the parameter should be set to 5). Only one of either thresholds or num_thresholds should be used.
name Metric name.

compute_confidence_interval Whether to compute confidence intervals for this metric.

Note that this may not completely remove the computational overhead involved in computing a given metric. This is only respected by the jackknife confidence interval method.

Methods

computations

View source

Creates computations associated with metric.

get_config

View source

Returns serializable config.

is_model_independent

View source

Returns true if the metric does not depend on a model.