当前位置: 首页 > news >正文

使用seaborn/matplotlib定制好看的confusion matrix

使用Python seaborn/matplotlib结合pretty-print-confusion-matrix可以制作好看的confusion matrix了。

import numpy as np
import pandas as pd
from pretty_confusion_matrix import pp_matrix #调用pp_matrix#pandas dataframe数据准备
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]])df_cm = pd.DataFrame(array, index=range(1, 7), columns=range(1, 7))
pp_matrix(df_cm, cmap='PuRd') #matrix plot

import numpy as np
from pretty_confusion_matrix import pp_matrix_from_data#vector数据准备
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)

pretty-print-confusion-matrix安装

pip install pretty-confusion-matrix

推荐阅读:

Python matplotlib保姆级教程

嫌Matplotlib繁琐?试试Seaborn!

《保姆级R可视化教程》来了!

http://www.lqws.cn/news/107209.html

相关文章:

  • ssm学习笔记day04
  • Vue3 + Typescript:类型使用记录 / 类型注解 / 积累
  • PV操作的C++代码示例讲解
  • AI与区块链:数据确权与模型共享的未来
  • Day-15【选择与循环】选择结构-if语句
  • 2025年微信小程序开发:AR/VR与电商的最新案例
  • sourcetree中的mercurial有什么用
  • 用PyTorch从零开始编写DeepSeek-V2
  • ONLYOFFICE 与 LocalAI:在 Ubuntu 上搭建 AI 文档编辑环境
  • 二进制安全-OpenWrt-uBus
  • 黑马程序员TypeScript课程笔记2(11-20)
  • MS1023/MS1224——10MHz 到 80MHz、10:1 LVDS 并串转换器(串化器)/串并转换器(解串器)
  • 【笔记】用命令手动下载并安装 tokenizers 库.whl文件(Python 3.12+)
  • Modbus转Ethernet IP网关助力罗克韦尔PLC数据交互
  • ESP32开发之LED闪烁和呼吸的实现
  • Tiktok App 登录账号、密码、验证码 XOR 加密算法
  • 道可云人工智能每日资讯|北京农业人工智能与机器人研究院揭牌
  • 【leetcode】15.三数之和
  • day20 奇异值SVD分解
  • 重新审视自回归语言模型的知识蒸馏
  • el-select 实现分页加载,切换也数滚回到顶部,自定义高度
  • Java求职者面试:Spring、Spring Boot、Spring MVC与MyBatis技术深度解析
  • 【C/C++】初步了解享元模式
  • 20250603在荣品的PRO-RK3566开发板的Android13下的使用命令行来查看RK3566的温度【显示优化版本】
  • 机器学习——使用多个决策树
  • Agent智能体应用教程系列(四):仅需几步,拥有自己专属的多agent智能体!
  • 计算A图片所有颜色占B图片红色区域的百分比
  • 关于物联网的基础知识(二)——物联网体系结构分层
  • 用Python训练自动驾驶神经网络:从零开始驾驭未来之路
  • Docker 部署前后端分离项目