def render_time_series(
    results: view_types.EvalResults,
    slicing_spec: Optional[Union[slicer.SingleSliceSpec,
                                 config_pb2.SlicingSpec]] = None,
    display_full_path: bool = False
) -> Optional[visualization.TimeSeriesViewer]:  # pytype: disable=invalid-annotation
    """Renders the time series view as widget.

  Args:
    results: An tfma.EvalResults.
    slicing_spec: A tfma.SlicingSpec determining the slice to show time series
      on. Show overall if not set.
    display_full_path: Whether to display the full path to model / data in the
      visualization or just show file name.

  Returns:
    A TimeSeriesViewer object if in Jupyter notebook; None if in Colab.
  """
    if slicing_spec and isinstance(slicing_spec, config_pb2.SlicingSpec):
        slicing_spec = slicer.SingleSliceSpec(spec=slicing_spec)
    slice_spec_to_use = slicing_spec if slicing_spec else slicer.SingleSliceSpec(
    )
    data = util.get_time_series(results, slice_spec_to_use, display_full_path)
    cfg = {
        'isModelCentric': results.get_mode() == constants.MODEL_CENTRIC_MODE
    }

    return visualization.render_time_series(data, cfg)
Exemple #2
0
def render_time_series(results, slice_spec=None, display_full_path=False):
    """Renders the time series view as widget.

  Args:
    results: An tfma.EvalResults.
    slice_spec: A slicing spec determining the slice to show time series on.
      Show overall if not set.
    display_full_path: Whether to display the full path to model / data in the
      visualization or just show file name.

  Returns:
    A TimeSeriesViewer object if in Jupyter notebook; None if in Colab.
  """
    slice_spec_to_use = slice_spec if slice_spec else SingleSliceSpec()
    data = util.get_time_series(results, slice_spec_to_use, display_full_path)
    config = {
        'isModelCentric': results.get_mode() == constants.MODEL_CENTRIC_MODE
    }

    return visualization.render_time_series(data, config)