Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

print labels on confusion_matrix

unique_label = np.unique([y_true, y_pred])
cmtx = pd.DataFrame(
    confusion_matrix(y_true, y_pred, labels=unique_label), 
    index=['true:{:}'.format(x) for x in unique_label], 
    columns=['pred:{:}'.format(x) for x in unique_label]
)
print(cmtx)
# Output:
#           pred:no  pred:yes
# true:no         3         0
# true:yes        2         1
Comment

print labels on confusion_matrix

import pandas as pd
cmtx = pd.DataFrame(
    confusion_matrix(y_true, y_pred, labels=['yes', 'no']), 
    index=['true:yes', 'true:no'], 
    columns=['pred:yes', 'pred:no']
)
print(cmtx)
# Output:
#           pred:yes  pred:no
# true:yes         1        2
# true:no          0        3
Comment

PREVIOUS NEXT
Code Example
Python :: django forms request 
Python :: transformers bert 
Python :: django rest framework viewset perform_update 
Python :: python contextmanager 
Python :: python how to add to a list 
Python :: how to change the disabled color in tkinter 
Python :: groupby where only 
Python :: install easygui conda 
Python :: plt add y gridlines 
Python :: python crash course 
Python :: python one line if without else 
Python :: how to set gpu python 
Python :: distinct query in django queryset 
Python :: sum of prime numbers python 
Python :: Got AttributeError when attempting to get a value for field `name` on serializer 
Python :: cv2 check if image is grayscale 
Python :: lemmatization 
Python :: get filename from path python 
Python :: how to convert integer to binary string python 
Python :: how to draw a single pixel in pyglet 
Python :: how to use css in php example 
Python :: python checking for NoneType 
Python :: python heatmap 
Python :: smallest number of 3 python 
Python :: gradient descent 
Python :: convert 2 level nested list to one level list in python 
Python :: Python Tkinter Frame Widget 
Python :: pandas parallelize for loop 
Python :: switch between frames in tkinter 
Python :: Python Tkinter PanedWindow Widget 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =