在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):wcipriano/pretty-print-confusion-matrix开源软件地址(OpenSource Url):https://github.com/wcipriano/pretty-print-confusion-matrix开源编程语言(OpenSource Language):Python 100.0%开源软件介绍(OpenSource Introduction):Confusion Matrix in PythonPlot a pretty confusion matrix (like Matlab) in python using seaborn and matplotlib Created on Mon Jun 25 14:17:37 2018 @author: Wagner Cipriano - wagnerbhbr This module get a pretty print confusion matrix from a NumPy matrix or from 2 NumPy arrays ( Installationpip install pretty-confusion-matrix Get StartedExamples: import numpy as np
import pandas as pd
from pretty_confusion_matrix import pp_matrix
array = np.array([[13, 0, 1, 0, 2, 0],
[0, 50, 2, 0, 10, 0],
[0, 13, 16, 0, 0, 3],
[0, 0, 0, 13, 1, 0],
[0, 40, 0, 1, 15, 0],
[0, 0, 0, 0, 0, 20]])
# get pandas dataframe
df_cm = pd.DataFrame(array, index=range(1, 7), columns=range(1, 7))
# colormap: see this and choose your more dear
cmap = 'PuRd'
pp_matrix(df_cm, cmap=cmap) import numpy as np
from pretty_confusion_matrix import pp_matrix_from_data
y_test = np.array([1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2,
3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5])
predic = np.array([1, 2, 4, 3, 5, 1, 2, 4, 3, 5, 1, 2, 3, 4, 4, 1, 4, 3, 4, 5, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 3, 3, 5, 1, 2, 3, 3, 5, 1, 2,
3, 4, 4, 1, 2, 3, 4, 1, 1, 2, 3, 4, 1, 1, 2, 3, 4, 1, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 4, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, 1, 2, 3, 4, 5])
pp_matrix_from_data(y_test, predic) References:
a) https://stackoverflow.com/a/51176855/1809554 b) https://www.programcreek.com/python/example/96197/seaborn.heatmap |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论