TFMA View¶
tensorflow_model_analysis.view
¶
Initializes TFMA's view rendering api.
Classes¶
SlicedMetrics
¶
Bases: NamedTuple('SlicedMetrics', [('slice', SliceKeyType), ('metrics', MetricsByOutputName)])
A tuple containing the metrics belonging to a slice.
The metrics are stored in a nested dictionary with the following levels:
- output_name: Optional output name associated with metric (for multi-output models). '' by default.
- sub_key: Optional sub key associated with metric (for multi-class models).
'' by default. See
tfma.metrics.SubKey
for more info. - metric_name: Name of the metric (
auc
,accuracy
, etc). - metric_value: A dictionary containing the metric's value. See
tfma.proto.metrics_for_slice_pb2.MetricValue
for more info.
Below is a sample SlicedMetrics:
(
(('color', 'green')),
{
'': { # default for single-output models
'': { # default sub_key for non-multiclass-classification models
'auc': {
'doubleValue': 0.7243943810462952
},
'accuracy': {
'doubleValue': 0.6488351225852966
}
}
}
}
)
ATTRIBUTE | DESCRIPTION |
---|---|
slice |
A 2-element tuple representing a slice. The first element is the key of a feature (ex: 'color'), and the second element is the value (ex: 'green'). An empty tuple represents an 'overall' slice (i.e. one that encompasses the entire dataset.
|
metrics |
A nested dictionary containing metric names and values.
|
SlicedPlots
¶
Bases: NamedTuple('SlicedPlots', [('slice', SliceKeyType), ('plot', PlotsByOutputName)])
A tuple containing the plots belonging to a slice.
ATTRIBUTE | DESCRIPTION |
---|---|
slice |
A 2-element tuple representing a slice. The first element is the key of a feature (ex: 'color'), and the second element is the value (ex: 'green'). An empty tuple represents an 'overall' slice (i.e. one that encompasses the entire dataset.
|
plot |
A dict mapping
|
Functions¶
render_plot
¶
render_plot(
result: EvalResult,
slicing_spec: Optional[
Union[SingleSliceSpec, SlicingSpec]
] = None,
output_name: Optional[str] = None,
class_id: Optional[int] = None,
top_k: Optional[int] = None,
k: Optional[int] = None,
label: Optional[str] = None,
) -> Optional[PlotViewer]
Renders the plot view as widget.
PARAMETER | DESCRIPTION |
---|---|
result
|
An tfma.EvalResult.
TYPE:
|
slicing_spec
|
The tfma.SlicingSpec to identify the slice. Show overall if unset.
TYPE:
|
output_name
|
A string representing the output name. |
class_id
|
A number representing the class id if multi class. |
top_k
|
The k used to compute prediction in the top k position. |
k
|
The k used to compute prediciton at the kth position. |
label
|
A partial label used to match a set of plots in the results. |
RETURNS | DESCRIPTION |
---|---|
Optional[PlotViewer]
|
A PlotViewer object if in Jupyter notebook; None if in Colab. |
Source code in tensorflow_model_analysis/view/widget_view.py
render_slicing_attributions
¶
render_slicing_attributions(
result: EvalResult,
slicing_column: Optional[str] = None,
slicing_spec: Optional[
Union[SingleSliceSpec, SlicingSpec]
] = None,
metric_name: Optional[str] = None,
weighted_example_column: Optional[str] = None,
event_handlers: Optional[
Callable[[Dict[str, Union[str, float]]], None]
] = None,
) -> Optional[SlicingMetricsViewer]
Renders the slicing metrics view as widget.
PARAMETER | DESCRIPTION |
---|---|
result
|
An tfma.EvalResult.
TYPE:
|
slicing_column
|
The column to slice on. |
slicing_spec
|
The tfma.SlicingSpec to filter results. If neither column nor spec is set, show overall.
TYPE:
|
metric_name
|
Name of attributions metric to show attributions for. Optional if only one metric used. |
weighted_example_column
|
Override for the weighted example column. This can be used when different weights are applied in different aprts of the model (eg: multi-head). |
event_handlers
|
The event handlers
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[SlicingMetricsViewer]
|
A SlicingMetricsViewer object if in Jupyter notebook; None if in Colab. |
Source code in tensorflow_model_analysis/view/widget_view.py
render_slicing_metrics
¶
render_slicing_metrics(
result: EvalResult,
slicing_column: Optional[str] = None,
slicing_spec: Optional[
Union[SingleSliceSpec, SlicingSpec]
] = None,
weighted_example_column: Optional[str] = None,
event_handlers: Optional[
Callable[[Dict[str, Union[str, float]]], None]
] = None,
) -> Optional[SlicingMetricsViewer]
Renders the slicing metrics view as widget.
PARAMETER | DESCRIPTION |
---|---|
result
|
An tfma.EvalResult.
TYPE:
|
slicing_column
|
The column to slice on. |
slicing_spec
|
The tfma.SlicingSpec to filter results. If neither column nor spec is set, show overall.
TYPE:
|
weighted_example_column
|
Override for the weighted example column. This can be used when different weights are applied in different aprts of the model (eg: multi-head). |
event_handlers
|
The event handlers
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[SlicingMetricsViewer]
|
A SlicingMetricsViewer object if in Jupyter notebook; None if in Colab. |
Source code in tensorflow_model_analysis/view/widget_view.py
render_time_series
¶
render_time_series(
results: EvalResults,
slicing_spec: Optional[
Union[SingleSliceSpec, SlicingSpec]
] = None,
display_full_path: bool = False,
) -> Optional[TimeSeriesViewer]
Renders the time series view as widget.
PARAMETER | DESCRIPTION |
---|---|
results
|
An tfma.EvalResults.
TYPE:
|
slicing_spec
|
A tfma.SlicingSpec determining the slice to show time series on. Show overall if not set.
TYPE:
|
display_full_path
|
Whether to display the full path to model / data in the visualization or just show file name.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Optional[TimeSeriesViewer]
|
A TimeSeriesViewer object if in Jupyter notebook; None if in Colab. |