def compare_tfma_analysis()

in tfx_airflow/notebooks/tfx_utils.py [0:0]


  def compare_tfma_analysis(self, model_id, other_model_id):
    """Compares TFMA metrics for `model_id` and `other_model_id`.

    Args:
      model_id: A `int` indicating the id of a `TFXArtifactTypes.MODEL` artifact
      other_model_id: A `int` indicating the id of another
          `TFXArtifactTypes.MODEL` artifact.

    Returns:
      A TimeSeriesViewer object if in Jupyter notebook; None if in Colab.
    """
    tfma_artifact, other_tfma_artifact = (
        self.get_dest_artifact_of_type(model_id, TFXArtifactTypes.MODEL_EVAL),
        self.get_dest_artifact_of_type(other_model_id,
                                       TFXArtifactTypes.MODEL_EVAL)
    )
    if tfma_artifact and other_tfma_artifact:
      eval_results = tfma.make_eval_results(
          [
              tfma.load_eval_result(tfma_artifact.uri),
              tfma.load_eval_result(other_tfma_artifact.uri)
          ], tfma.constants.MODEL_CENTRIC_MODE)
      return tfma.view.render_time_series(
          eval_results, tfma.slicer.slicer.SingleSliceSpec())