Adding string classes directly in ConfusionMatrix removes all stats.
lewiuberg opened this issue ยท 5 comments
Description
I was going to add my own custom labels in ConfusionMatrix. However, this blanked out all other values.
Steps/Code to Reproduce
Input:
cm1 = ConfusionMatrix(
y_true, y_pred, digit=5, classes=["normal", "lgg", "hgg"]
)
Output:
/Users/lewiuberg/Library/Caches/pypoetry/virtualenvs/tumorclass.info-OrbyvotM-py3.9/lib/python3.9/site-packages/pycm/pycm_util.py:387: RuntimeWarning: Used classes is not a subset of classes in actual and predict vectors.
warn(CLASSES_WARNING, RuntimeWarning)
Input:
cm1
Output:
pycm.ConfusionMatrix(classes: ['normal', 'lgg', 'hgg'])
Input:
print(cm1)
Output:
Predict normal lgg hgg
Actual
normal 0 0 0
lgg 0 0 0
hgg 0 0 0
Overall Statistics :
95% CI (None,None)
ACC Macro None
ARI None
AUNP None
AUNU None
Bangdiwala B None
...
Operating System
macOS Monterey V 12.0.1
Python Version
3.9
PyCM Version (Use : pycm.__version__
)
3.3
@lewiuberg
It's not a bug!
classes
is for controlling labels manually, so the user has this option to eliminate auto-detected labels or add new ones.
@alirezazolanvari @sadrasabouri What's your opinion?
@lewiuberg It's not a bug!
classes
is for controlling labels manually, so the user has this option to eliminate auto-detected labels or add new ones. @alirezazolanvari @sadrasabouri What's your opinion?
Yes I think so.
I wonder if there is a misunderstanding here.
We added the classes
parameter so that one can define which classes are going to be included in the Confusion Matrix but as I figured out here, you want to rename your class names to ["normal", "lgg", "hgg"]
, right @lewiuberg ?
I think the cm.relabel
is what you're looking for.
Hi!
Yes I think I misunderstood the functionality. Thanks for clarifying ๐๐ป
How about doing something like this to enable custom labels right of the bat?
cm = ConfusionMatrix(
y_true, y_pred, digit=5, labels=["normal", "lgg", "hgg"]
)
We will resolve this discussion through #412