From 7b968ee34e12312bbcda5b371a276228bc3e4ca2 Mon Sep 17 00:00:00 2001 From: Doojin Park Date: Wed, 4 Dec 2024 07:33:51 +0000 Subject: [PATCH] Update evaluator config to work with taxi keras models --- tfx/orchestration/kubeflow/v2/test_utils.py | 37 +++++++++++---------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/tfx/orchestration/kubeflow/v2/test_utils.py b/tfx/orchestration/kubeflow/v2/test_utils.py index 6491e73317..98cc73105f 100644 --- a/tfx/orchestration/kubeflow/v2/test_utils.py +++ b/tfx/orchestration/kubeflow/v2/test_utils.py @@ -234,25 +234,28 @@ def create_pipeline_components( model_blessing=tfx.dsl.Channel( type=tfx.types.standard_artifacts.ModelBlessing)).with_id( 'Resolver.latest_blessed_model_resolver') - # Set the TFMA config for Model Evaluation and Validation. + # Uses TFMA to compute a evaluation statistics over features of a model and + # perform quality validation of a candidate model (compared to a baseline). eval_config = tfma.EvalConfig( - model_specs=[tfma.ModelSpec(signature_name='eval')], - metrics_specs=[ - tfma.MetricsSpec( - metrics=[tfma.MetricConfig(class_name='ExampleCount')], - thresholds={ - 'binary_accuracy': - tfma.MetricThreshold( - value_threshold=tfma.GenericValueThreshold( - lower_bound={'value': 0.5}), - change_threshold=tfma.GenericChangeThreshold( - direction=tfma.MetricDirection.HIGHER_IS_BETTER, - absolute={'value': -1e-10})) - }) + model_specs=[ + tfma.ModelSpec( + signature_name='serving_default', label_key='tips_xf', + preprocessing_function_names=['transform_features']) ], - slicing_specs=[ - tfma.SlicingSpec(), - tfma.SlicingSpec(feature_keys=['trip_start_hour']) + slicing_specs=[tfma.SlicingSpec()], + metrics_specs=[ + tfma.MetricsSpec(metrics=[ + tfma.MetricConfig( + class_name='BinaryAccuracy', + threshold=tfma.MetricThreshold( + value_threshold=tfma.GenericValueThreshold( + lower_bound={'value': 0.6}), + # Change threshold will be ignored if there is no + # baseline model resolved from MLMD (first run). + change_threshold=tfma.GenericChangeThreshold( + direction=tfma.MetricDirection.HIGHER_IS_BETTER, + absolute={'value': -1e-10}))) + ]) ]) evaluator = tfx.components.Evaluator( examples=example_gen.outputs['examples'],