PTransform for performing extraction, evaluation, and writing results.
tfma.ExtractEvaluateAndWriteResults(
eval_shared_model: Optional[tfma.types.EvalSharedModel
] = None,
eval_config: Optional[tfma.EvalConfig
] = None,
extractors: Optional[List[extractor.Extractor]] = None,
evaluators: Optional[List[evaluator.Evaluator]] = None,
writers: Optional[List[writer.Writer]] = None,
output_path: Optional[str] = None,
display_only_data_location: Optional[str] = None,
display_only_file_format: Optional[str] = None,
slice_spec: Optional[List[slicer.SingleSliceSpec]] = None,
write_config: Optional[bool] = True,
compute_confidence_intervals: Optional[bool] = False,
min_slice_size: int = 1,
random_seed_for_testing: Optional[int] = None,
tensor_adapter_config: Optional[tensor_adapter.TensorAdapterConfig] = None,
schema: Optional[schema_pb2.Schema] = None,
config_version: Optional[int] = None
) -> Dict[str, beam.PCollection]
Used in the notebooks
Used in the tutorials |
---|
Users who want to construct their own Beam pipelines instead of using the lightweight run_model_analysis functions should use this PTransform.
Example usage:
eval_config = tfma.EvalConfig(model_specs=[...], metrics_specs=[...],
slicing_specs=[...])
eval_shared_model = tfma.default_eval_shared_model(
eval_saved_model_path=model_location, eval_config=eval_config)
tfx_io = tf_example_record.TFExampleRecord(
file_pattern=data_location,
raw_record_column_name=tfma.ARROW_INPUT_COLUMN)
with beam.Pipeline(runner=...) as p:
_ = (p
| 'ReadData' >> tfx_io.BeamSource()
| 'ExtractEvaluateAndWriteResults' >>
tfma.ExtractEvaluateAndWriteResults(
eval_shared_model=eval_shared_model,
eval_config=eval_config,
...))
result = tfma.load_eval_result(output_path=output_path)
tfma.view.render_slicing_metrics(result)
Note: If running with an EvalSavedModel (i.e. the ModelSpec has signature_name
"eval"), then instead of using the tfxio.BeamSource() code use the following
beam.io.ReadFromTFRecord(data_location)
Note that the exact serialization format is an internal implementation detail and subject to change. Users should only use the TFMA functions to write and read the results.
Returns | |
---|---|
A dict of writer results keyed by the writer stage name. |