python - 使用 nltk 中的 meteor_score 模块评估模型时,如何实现流星分数?
问题描述
我目前有 2 个文件,reference.txt 和 model.txt。这两个文本文件包含原始字幕和训练后生成的字幕。
我可以简单地执行以下操作来获得流星分数:
score = nltk.translate.meteor_score.meteor_score(reference, model)
print(np.mean(meteor_score))
我也看过https://github.com/tylin/coco-caption但我不知道如何实现这一点。
解决方案
让我们从定义术语开始
参考:实际文本/基本事实。如果有多个人为同一个数据点生成基本事实,您将有多个参考,并且所有参考都被认为是正确的
假设:候选/预测。
假设这 2 个人看一张图片,他们在标题
- 这是一个苹果
- 那是一个苹果
现在您的模型查看图像并预测
- 这棵树上有一个苹果
您可以计算预测使用效果的meteor_score
print (nltk.translate.meteor_score.meteor_score(
["this is an apple", "that is an apple"], "an apple on this tree"))
print (nltk.translate.meteor_score.meteor_score(
["this is an apple", "that is an apple"], "a red color fruit"))
输出:
0.6233062330623306
0.0
在您的情况下,您必须阅读reference.txt
一个列表并将预测模型类似地建模到另一个列表中。现在你必须得到meteor_score
第一个列表中的每一行和第二个列表中的每一行,最后取一个平均值。
推荐阅读
- spring-boot - Spring Boot + gcp datastore + datastore 模拟器获取 INVALID_ARGUMENT 遇到“OR”/“IN”
- reactjs - React useEffect 加载新的但不会清除旧的
- sql-server - System.Data.SqlClient.SqlException:'附近的语法不正确
- ruby - Ruby:(如果可能)如何在程序执行以构建菜单方法时在 while 循环中构建 case 语句?
- php - 合并具有相同键名的多维数组
- javascript - AJAX 使用 POST 映射将所有空数据发送到 Spring 控制器?
- ios - `dd of=/dev/rdisk4` 在越狱的 iOS 上给出 `Operation not allowed`
- batch-file - 如果我运行我的 .bat(打开 FF),我可以看到窗口。从任务计划程序,它在 FF 中打开 url,但它不可见。我怎样才能明显地打开它?
- java - Spring Cloud Gateway 不适用于 DiscoveryClientRouteDefinitionLocator
- serialization - Flatbuffer 线尺寸大于预期