【问题标题】:incorrect confusion matrix plot不正确的混淆矩阵图
【发布时间】:2019-11-23 12:41:34
【问题描述】:

在使用 pandas 数据框绘制混淆矩阵时,y 轴的末端会中途截断?

这是我得到的:

我使用了来自这里的代码 How can I plot a confusion matrix? 使用 pandas 数据框:

import seaborn as sn
import pandas as pd
import matplotlib.pyplot as plt

array = [[13,1,1,0,2,0],
    [3,9,6,0,1,0],
    [0,0,16,2,0,0],
    [0,0,0,13,0,0],
    [0,0,0,0,15,0],
    [0,0,1,0,0,15]]        
df_cm = pd.DataFrame(array, range(6),range(6))
#plt.figure(figsize = (10,7))
sn.set(font_scale=1.4)#for label size
sn.heatmap(df_cm, annot=True,annot_kws={"size": 16})# font size

【问题讨论】:

    标签: seaborn confusion-matrix


    【解决方案1】:

    正如sikisis所建议的那样

    以下解决了我的问题

    pip install matplotlib==3.1.0

    【讨论】:

      【解决方案2】:

      我解决了这个问题,我认为this post 解释了它发生的原因。

      简单来说,matplotlib 3.1.1 破坏了 seaborn heatmaps;您可以通过降级到 matplotlib 3.1.0 来解决它。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-08-30
        • 2021-10-07
        • 2020-02-23
        • 2014-07-09
        • 2015-12-17
        • 2020-10-01
        • 2012-01-20
        • 2019-11-23
        相关资源
        最近更新 更多