9
$\begingroup$

I'm looking for a Python library that can compute the confusion matrix for multi-label classification.


FYI:

$\endgroup$
6
  • $\begingroup$ What did you end up doing? $\endgroup$ Commented Oct 13, 2016 at 22:27
  • $\begingroup$ @MortezaShahriariNia I stayed monolabeled. $\endgroup$ Commented Oct 13, 2016 at 22:33
  • $\begingroup$ what would a theoretical multilabel confusion matrix look like? I do not think it applies, does it? $\endgroup$ Commented May 25, 2017 at 4:05
  • 3
    $\begingroup$ very funny that all 3 answers to this question are of such remarkably low quality. $\endgroup$ Commented Aug 11, 2017 at 6:41
  • $\begingroup$ Not aware of any packages, but you could perhaps consider all possible multi-label combination as a separate class and use some of the already-available packages for multi-class. Then, from that confusion, build your multi-label matrix $\endgroup$ Commented Jan 30, 2018 at 22:20

7 Answers 7

3
$\begingroup$

Also take a look at scikit-multilearn. It is a very good library that extends sklearn for multi-label learning. However, I'm not sure how the confusion matrix works for multi-label problems...

This guy claims he has solved it.

$\endgroup$
1
  • $\begingroup$ skmultilearn has no confusion matrix utils. $\endgroup$ Commented Jun 10, 2021 at 19:34
2
$\begingroup$

Although this question is old, I am writing this answer for new audience.
scikit-learn now supports confusion matrix for multi-label classification.

https://scikit-learn.org/stable/modules/generated/sklearn.metrics.multilabel_confusion_matrix.html

$\endgroup$
1
$\begingroup$

There are many different parameters which can evaluate the performance of your method by comparing the real and predicted labels. I suggest PyCM module which can give a vast variety these parameters which are suitable for multi-class classification.

$\endgroup$
1
1
$\begingroup$

Try mlxtend. Here's an example of multi-class case.

enter image description here

$\endgroup$
2
  • 3
    $\begingroup$ how about multi-label multi-class? Is it supported? $\endgroup$ Commented Feb 15, 2017 at 17:49
  • $\begingroup$ No, this library does not support multi-label $\endgroup$ Commented Jun 10, 2021 at 19:30
0
$\begingroup$

Sklearn has a method for it using which you can compute confusion matrix for multi class.

from sklearn import cross_validation confusion_matrix(original, Predicted) 
$\endgroup$
1
0
$\begingroup$

Scikit-learn does support multi-label confusion matrix. See the links below for documentation and user guide:

http://scikit-learn.org/stable/modules/generated/sklearn.metrics.confusion_matrix.html

http://scikit-learn.org/stable/modules/model_evaluation.html#confusion-matrix

$\endgroup$
1
  • 1
    $\begingroup$ Thank you, that's why I am looking for an alternative option :-) $\endgroup$ Commented Feb 15, 2017 at 17:48
0
$\begingroup$

Look at sed_eval library. It is developed for evaluating event detection in audio which is a multi-label problem (as in each audio, multiple events exist). They have many evaluation options, which might fit to your needs. You can get the true-positive rate, ... and from there computing the confusion matrix is not that hard.

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.