Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Confusion matrix visualizes target and predictions on wrong axes #3733

Closed
areshytko opened this issue May 10, 2020 · 4 comments · Fixed by #3817
Closed

[BUG] Confusion matrix visualizes target and predictions on wrong axes #3733

areshytko opened this issue May 10, 2020 · 4 comments · Fixed by #3817
Assignees
Labels
area/frontend help wanted The community is welcome to contribute. kind/bug priority/p0 status/triaged Whether the issue has been explicitly triaged

Comments

@areshytko
Copy link

What steps did you take:

  1. Run the following code:
from typing import NamedTuple
def conf_m() -> NamedTuple('conf_m_result', [('mlpipeline_ui_metadata', 'UI_metadata')]):
    import json
    from collections import namedtuple
    cm_data = 'False,False,22\nFalse,True,484\nTrue,False,12\nTrue,True,539\n'
    vocab = [False, True]
    metadata = {
        'outputs' : [{
            'type': 'confusion_matrix',
            'format': 'csv',
            'schema': [
                {'name': 'target', 'type': 'CATEGORY'},
                {'name': 'predicted', 'type': 'CATEGORY'},
                {'name': 'count', 'type': 'NUMBER'},
            ],
            'storage': 'inline',
            'source': cm_data,
            'labels': list(map(str, vocab)),
        }]
    }
    print(json.dumps(metadata))
    conf_m_result = namedtuple('conf_m_result', ['mlpipeline_ui_metadata'])
    return conf_m_result(json.dumps(metadata))

cm_op = kfp.components.func_to_container_op(conf_m)

@kfp.dsl.pipeline(name='test conf matrix')
def pipeline():
    op1 = cm_op()

kfp.Client().create_run_from_pipeline_func(pipeline, arguments={})
  1. See result in KFP UI

What happened:

Axes were mixed up:

image

for the data:

image

What did you expect to happen:

Targets on the y-axis, predictions on the x-axis

Environment:

How did you deploy Kubeflow Pipelines (KFP)?

kubectl apply -k

KFP version: 0.5

KFP SDK version: 0.5.0

Anything else you would like to add:

[Miscellaneous information that will assist in solving the issue.]

/kind bug
/area frontend

@Bobgy
Copy link
Contributor

Bobgy commented May 15, 2020

/cc @numerology
I'm not familiar with the scope, is this the usual convention of showing a confusion matrix?
If yes, can you switch your schema order, to put predicted as the first item?

'schema': [
                {'name': 'target', 'type': 'CATEGORY'},
                {'name': 'predicted', 'type': 'CATEGORY'},
                {'name': 'count', 'type': 'NUMBER'},
            ],

@Bobgy Bobgy added the area/ux label May 15, 2020
@Bobgy Bobgy self-assigned this May 15, 2020
@Bobgy Bobgy added help wanted The community is welcome to contribute. status/triaged Whether the issue has been explicitly triaged labels May 15, 2020
@Bobgy
Copy link
Contributor

Bobgy commented May 18, 2020

@areshytko is above workaround good for you?

@areshytko
Copy link
Author

areshytko commented May 18, 2020

Hey @Bobgy. Thanks for the reply.

The thing is not about the convention, the data on the plot is wrong: if you sum all targets on the plot you will get: 484+539 as True. And if you do it the original data in the table, you'll get: 539 + 12.

The workaround is confusing for the user because the order of columns in the data and in the provided metadata will differ.

@Bobgy
Copy link
Contributor

Bobgy commented May 19, 2020

@areshytko Thanks for the detailed explanation! I see, that's a bug indeed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/frontend help wanted The community is welcome to contribute. kind/bug priority/p0 status/triaged Whether the issue has been explicitly triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants