ConfusionMatrixDisplay

I have tried to run ConfusionMatrixDisplay (in python3) which is part of sklearn.metrics, but it is not supported.

How can I make it to work?

Hi,

Could you share more details about this?

Suppose you have built sklearn from source, is that correct?
If yes, do you use the branch with ConfusionMatrixDisplay implementation?

Thanks.

Hi @AastaLLL,
thanks fior the prompt response.

I actually was wandering whether the library was already implemented but I did not invoked it correctly:
following is a snippet from code that fails:


from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay

oModel = KNeighborsClassifier(n_neighbors=maxK)
vHatY = cross_val_predict(oModel, mX, vY, cv=cv)
mConfusion = confusion_matrix(vY, vHatY)
accuracy = np.mean(vY == vHatY)
DisplayConfusionMatrix(mConfusion, accuracy) <= this one fails.

Though if you’re saying that I can recompile the code please advise how should I do it.
Regards.

Hi,

It looks like you can import the sklean correctly.
But meet error when calling DisplayConfusionMatrix?

Could you share what kind of error do you meet when the failure occurs?

Thanks.

hi,
the error that I receive upon invoking the DisplayConfusionMatrix function is:

Traceback (most recent call last):
File “/home/nvidia/TIMIT_Exercise/BinaryClassification.py”, line 149, in
DisplayConfusionMatrix(mConfusion, accuracy)
File “/home/nvidia/TIMIT_Exercise/BinaryClassification.py”, line 45, in DisplayConfusionMatrix
ConfusionMatrixDisplay(mConfusion).plot(values_format=‘g’, ax=ax)
NameError: name ‘ConfusionMatrixDisplay’ is not defined

Hope that’ll assist your support.
Regards.

Hi,

It seems more related to the custom implementation.
Could you share a workable standalone BinaryClassification.py with us for reproducing?

Thanks.

Hi,

you could look @ ConfusionMatrixDisplay - #4 by igal.kroyter for snippet of the code.

Hi,

We test the official sample for ConfusionMatrixDisplay and it can work correctly on Xaiver.

It looks like there is some issue with your custom implementation.
Could you give our example a try?

We install skicit-learn v0.24.2.
test.py (449 Bytes)

$ export DISPLAY=:0
$ python3 test.py

Thanks.