【问题标题】:How do I show BERT classification metrics result?如何显示 BERT 分类指标结果?
【发布时间】:2021-10-26 04:32:23
【问题描述】:

我目前正在学习如何使用 BERT 分类。我遵循的教程之一是这个:https://towardsdatascience.com/multi-label-multi-class-text-classification-with-bert-transformer-and-keras-c6355eccb63a

作者展示了分类指标(如图所示),但没有包含代码。 如何创建这些指标?

作者的分类指标

【问题讨论】:

    标签: python machine-learning text-classification bert-language-model


    【解决方案1】:

    这张表肯定是用 sklearn classification_report function 制作的。

    类名可以使用target_names参数显示。

    【讨论】:

    • 感谢您的回答!在classification_report() 中,我需要输入y_truey_pred。我发现y_pred是使用model.predict(test_x)得到的。但是当我运行代码时,它返回一个错误:ValueError: Unsupported value type BatchEncoding returned by IteratorSpec._serialize 后来,我尝试将 test_x 从批处理转换为列表,但随后又出现错误:ValueError: Failed to convert a NumPy array to a Tensor (Unsupported object type list) Trying to convert it again using asarray() and将其插入model.predict() 会返回相同的错误。
    • @KuugyR 你应该问一个关于这个的新问题(提供你的代码,以便人们可以看到问题来自哪里)。请注意,您也可以在datascience.stackexchange.com 上提问
    • 感谢您的建议。我会在那里问问题。
    猜你喜欢
    • 2021-04-29
    • 2020-11-08
    • 1970-01-01
    • 1970-01-01
    • 2020-11-16
    • 2022-10-14
    • 1970-01-01
    • 2013-05-28
    • 2015-01-31
    相关资源
    最近更新 更多