GithubHelp home page GithubHelp logo

Comments (5)

github-actions avatar github-actions commented on June 20, 2024

Hi! thanks for your contribution!, great first issue!

from torchmetrics.

SpontaneousDuck avatar SpontaneousDuck commented on June 20, 2024

So I guess the more usefull expected behavior would be the Multi-Label Confusion Matrix output like sklearn.metrics.multilabel_confusion_matrix where the output is (n_outputs, 2, 2). It appears like torchmetrics is kind of doing this but extending the 2x2 matrix to the size of num_classes where the multi-label confusion matrix occupies the first two rows and columns. pytorchmetrics is also then summing along the first axis and only returning the overall matrix instead of class-wise.

from torchmetrics.

FlorianMF avatar FlorianMF commented on June 20, 2024

I'm in the same case as you.
The docstring of confusion_matrix says that it works for multi-label targets.
It calculates the confusion matrix in a binary way. Using num_classes > 2 or num_classes=2 gives the same result except for the additional rows and colums (all zeros) for the additional classes.

I don't expect the same output as you. In my opinion the output should be a list/Tensor of binary confusion matrices of length num_classes like in this sklearn example

Personally I iterate over the the predictions and targets as _auroc_compute does:

[confusion_matrix(class_preds[:, idx], y_true[:, idx], num_classes=2)
                  for idx in range(class_preds.shape[-1])]

from torchmetrics.

SpontaneousDuck avatar SpontaneousDuck commented on June 20, 2024

Thanks for the response! Yeah I look in to sklearn and understand what I should be getting now. I am doing what you suggested to get the response now. confusion_matrix should match sklearn's if it was performing correctly right?

from torchmetrics.

FlorianMF avatar FlorianMF commented on June 20, 2024

IMO yes if the philosophy is to create a pytorch optimised sklearn.

from torchmetrics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.