【问题标题】:Problems with visualization classification_report可视化分类报告的问题
【发布时间】:2020-12-24 06:32:25
【问题描述】:

我尝试了绘图分类报告,但在我的问题中只有 2 个类(0 和 1),当我调用分类报告时,他的输出是:

enter image description here

我的模型是一个带有 Glove 嵌入的 LSTM,用于情感分类,这是一个架构:

Model: "sequential_6"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
embedding_6 (Embedding)      (None, 55, 300)           68299200  
_________________________________________________________________
spatial_dropout1d_12 (Spatia (None, 55, 300)           0         
_________________________________________________________________
lstm_12 (LSTM)               (None, 55, 128)           219648    
_________________________________________________________________
lstm_13 (LSTM)               (None, 55, 64)            49408     
_________________________________________________________________
spatial_dropout1d_13 (Spatia (None, 55, 64)            0         
_________________________________________________________________
dense_18 (Dense)             (None, 55, 512)           33280     
_________________________________________________________________
dropout_6 (Dropout)          (None, 55, 512)           0         
_________________________________________________________________
dense_19 (Dense)             (None, 55, 64)            32832     
_________________________________________________________________
dense_20 (Dense)             (None, 55, 1)             65        
=================================================================
Total params: 68,634,433
Trainable params: 335,233
Non-trainable params: 68,299,200 

【问题讨论】:

  • 您可以在将y_predy_test 的形状传递给argmax 函数之前添加它吗?
  • 你检查y_pred是否只包含两个值10

标签: tensorflow machine-learning scikit-learn


【解决方案1】:

您可以将classification_report 的输出定义为dict(),这样您就可以通过pandas.DataFrame.from_dict() 将其读取为pandas DataFrame,如下所示:

import pandas as pd

display(pd.DataFrame.from_dict(classification_report(y_true, y_pred, output_dict=True)).T)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-06-10
    • 2013-10-20
    • 1970-01-01
    • 1970-01-01
    • 2018-01-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多