sepandhaghighi / pycm

Multi-class confusion matrix library in Python
http://pycm.io
MIT License
1.45k stars 124 forks source link

Multi label base architecture #507

Closed sadrasabouri closed 1 year ago

sadrasabouri commented 1 year ago

Reference Issues/PRs

211

What does this implement/fix? Explain your changes.

This PR will add pycm_multilabel_cm.py file which contains main architecture for MultiLabelCM. With this new class you can use PyCM for your multi-label tasks. An example of this class use-case is provided below:

>>> from pycm import MultiLabelCM
>>> mlcm = MultiLabelCM([{'dog'}, {'cat', 'dog'}], [{'cat'}, {'cat'}]) # list of set mode
>>> mlcm.samplewise_cm(0)
pycm.ConfusionMatrix(classes: [0, 1])
>>> mlcm.samplewise_cm(1)
pycm.ConfusionMatrix(classes: [0, 1])
>>> mlcm.classwise_cm('cat')
pycm.ConfusionMatrix(classes: [0, 1])
>>> mlcm.classwise_cm('dog')
pycm.ConfusionMatrix(classes: [0, 1])

Below are some changes which will be occurring after merging this PR:

Added

codecov[bot] commented 1 year ago

Codecov Report

Merging #507 (e3a4e9e) into dev (342d1c3) will increase coverage by 0.02%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##              dev     #507      +/-   ##
==========================================
+ Coverage   99.31%   99.33%   +0.02%     
==========================================
  Files          13       14       +1     
  Lines        3031     3112      +81     
  Branches      451      467      +16     
==========================================
+ Hits         3010     3091      +81     
  Misses          8        8              
  Partials       13       13              
Impacted Files Coverage Δ
pycm/pycm_error.py 100.00% <100.00%> (ø)
pycm/pycm_multilabel_cm.py 100.00% <100.00%> (ø)
pycm/pycm_param.py 100.00% <100.00%> (ø)