def extract_output( self, accumulator: _Matrices ) -> Dict[metric_types.PlotKey, metrics_for_slice_pb2.MultiLabelConfusionMatrixAtThresholds]: pb = metrics_for_slice_pb2.MultiLabelConfusionMatrixAtThresholds() for threshold in sorted(accumulator.keys()): matrix = pb.matrices.add(threshold=threshold) for k in sorted(accumulator[threshold].keys()): matrix.entries.add( actual_class_id=k.actual_class_id, predicted_class_id=k.predicted_class_id, false_negatives=accumulator[threshold][k].false_negatives, true_negatives=accumulator[threshold][k].true_negatives, false_positives=accumulator[threshold][k].false_positives, true_positives=accumulator[threshold][k].true_positives) return {self._key: pb}
def extract_output( self, accumulator: _Matrices ) -> Dict[metric_types.PlotKey, metrics_for_slice_pb2.MultiLabelConfusionMatrixAtThresholds]: pb = metrics_for_slice_pb2.MultiLabelConfusionMatrixAtThresholds() for threshold in sorted(accumulator.keys()): # Convert -epsilon and 1.0+epsilon back to 0.0 and 1.0. if threshold == -_EPSILON: t = 0.0 elif threshold == 1.0 + _EPSILON: t = 1.0 else: t = threshold matrix = pb.matrices.add(threshold=t) for k in sorted(accumulator[threshold].keys()): matrix.entries.add( actual_class_id=k.actual_class_id, predicted_class_id=k.predicted_class_id, false_negatives=accumulator[threshold][k].false_negatives, true_negatives=accumulator[threshold][k].true_negatives, false_positives=accumulator[threshold][k].false_positives, true_positives=accumulator[threshold][k].true_positives) return {self._key: pb}