From 2efbc06c8c7da561a1604ca5ccb848df75960d79 Mon Sep 17 00:00:00 2001 From: Bradley Jiang Date: Wed, 12 Dec 2018 14:22:59 -0800 Subject: [PATCH] Remove the workaround in confusion matrix component for correctly handling boolean cases. --- .../local/confusion_matrix/src/confusion_matrix.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/components/local/confusion_matrix/src/confusion_matrix.py b/components/local/confusion_matrix/src/confusion_matrix.py index aa03226d15c..f7d2701e727 100644 --- a/components/local/confusion_matrix/src/confusion_matrix.py +++ b/components/local/confusion_matrix/src/confusion_matrix.py @@ -53,13 +53,6 @@ def main(argv=None): if args.target_lambda: df['target'] = df.apply(eval(args.target_lambda), axis=1) - # Convert "True" to "True_" and "False" to "False_" for frontend to work. - # TODO: Investigate frontend handling of boolean values. - # https://github.com/kubeflow/pipelines/issues/446 - convert_fn = lambda x: str(x) + '_' if str(x).lower() in ['true', 'false'] else x - df['target'] = df['target'].apply(convert_fn) - df['predicted'] = df['predicted'].apply(convert_fn) - vocab = list(df['target'].unique()) cm = confusion_matrix(df['target'], df['predicted'], labels=vocab) data = [] @@ -83,7 +76,8 @@ def main(argv=None): {'name': 'count', 'type': 'NUMBER'}, ], 'source': cm_file, - 'labels': vocab, + # Convert vocab to string because for bealean values we want "True|False" to match csv data. + 'labels': list(map(str, vocab)), }] } with file_io.FileIO('/mlpipeline-ui-metadata.json', 'w') as f: