def expand(self, confusion_matrix):
     # The confusion matrix is an output of a global aggregation and should
     # therefore be on a single shard.
     (confusion_matrix  # pylint: disable=expression-not-assigned
      | 'Write Confusion Matrix' >> beam.io.textio.WriteToText(
          self._path,
          shard_name_template='',
          coder=mlcoders.CsvCoder(['target', 'predicted', 'count'],
                                  ['count'])))
 def expand(self, precision_recall):
     # Precision/recall is an output of a global aggregation and should
     # therefore be on a single shard.
     (precision_recall  # pylint: disable=expression-not-assigned
      | 'Write Precision Recall' >> beam.io.textio.WriteToText(
          self._path,
          shard_name_template='',
          coder=mlcoders.CsvCoder(
              ['label', 'threshold', 'precision', 'recall', 'f1score'],
              ['threshold', 'precision', 'recall', 'f1score'])))