class_docstr: Multi-label confusion matrix.
  
  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.
class_docstr_tok: ["Multi-label","confusion","matrix",".","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","."]
docstr: Initializes multi-label confusion matrix.
  
  Args:
    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.
docstr_tok: ["Initializes","multi-label","confusion","matrix",".","Args",":","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","."]
code: def __init__(
      self,
      thresholds: Optional[List[float]] = None,
      num_thresholds: Optional[int] = None,
      name: str = MULTI_LABEL_CONFUSION_MATRIX_PLOT_NAME,
  ):
      """Initializes multi-label confusion matrix.
  
      Args:
        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.
      """
      super().__init__(
          metric_util.merge_per_key_computations(
              _multi_label_confusion_matrix_plot
          ),
          thresholds=thresholds,
          num_thresholds=num_thresholds,
          name=name,
      )
  
file_path: model-analysis/tensorflow_model_analysis/metrics/multi_label_confusion_matrix_plot.py
imports: from typing import Dict, Iterable, List, Optional, NamedTuple
  import apache_beam
  from tensorflow_model_analysis.metrics import metric_types
  from tensorflow_model_analysis.metrics import metric_util
  from tensorflow_model_analysis.proto import config_pb2
  from tensorflow_model_analysis.proto import metrics_for_slice_pb2
label_desc: Use image node_id 1 to create a new MultiLabelConfusionMatrixPlot object from inherited base classes: metric_types with example: obj = MultiLabelConfusionMatrixPlot(thresholds, num_thresholds, name)