【问题标题】:How to calculate confusion matrix for a training model ? (from this code)如何计算训练模型的混淆矩阵? (从此代码)
【发布时间】:2018-10-16 13:13:43
【问题描述】:

如何计算这个训练模型的混淆矩阵?

    model = Model([encoder_inputs, decoder_inputs], decoder_outputs)
    model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy'])
    history = model.fit([encoder_input_data, decoder_input_data], decoder_target_data,
          batch_size=batch_size,
          epochs=epochs,
          validation_split=0.2,
          verbose=1)
    model.summary()

【问题讨论】:

    标签: python scikit-learn keras chatbot


    【解决方案1】:

    假设您有训练和测试集并且y_true 保持预期结果:

    1. 训练你的模型
    2. 将您的预测值存储在变量y_predicted
    3. 从 skear (from sklearn.metrics import confusion_matrix) 导入混淆矩阵
    4. 执行confusion_matrix(y_true, y_predicted)
    5. 享受调整模型的乐趣;)

    【讨论】:

    • 请从我的代码 sn-p 中将其定义为 y_true 和 y_predicted。 =================================================模型=模型([encoder_inputs,decoder_inputs],decoder_outputs)model.compile(optimizer='rmsprop',loss='categorical_crossentropy',metrics=['accuracy'])history = model.fit([encoder_input_data,decoder_input_data],decoder_target_data,batch_size= batch_size, epochs=epochs, validation_split=0.2, verbose=1) model.summary()
    • @rzr 请不要不要使用 cmets 空间发布代码 - 它实际上是不可读的!如有必要,编辑和更新您的问题,但在这里您只是重新发布问题中的代码,这是无用的......
    • @rzr 我建议您看一些可能对您有所帮助的教程 - 了解拆分为训练/[验证或测试] 集(并解释它们是什么),因为我认为您训练你的模型在整个训练集上,如果你想在训练中使用的数据上建立混淆矩阵,它可能会给你一些误导性的结果。在这里你有关于 Keras 的很好的教程 - youtube.com/… 或者如果你想了解更多幕后发生的事情,你可以看看 Andrew Ng ML 课程。
    猜你喜欢
    • 2020-05-22
    • 2017-02-25
    • 2018-04-01
    • 2019-10-08
    • 2018-04-09
    • 1970-01-01
    • 2020-01-26
    • 1970-01-01
    相关资源
    最近更新 更多