【问题标题】:How to get scores in output file from Tensorflow ranking sysytem?如何从 Tensorflow 排名系统获取输出文件中的分数?
【发布时间】:2019-07-29 09:07:47
【问题描述】:

我无法从评分函数中获取文件中每一行的分数作为输出。

我正在使用评分函数在 Jupyter 笔记本中使用 Python 在推荐引擎中对我的文档进行排名。我正在使用下面的代码来评估我的测试数据 -

def eval_metric_fns():
metric_fns = {}
  metric_fns.update({
      "metric/ndcg@%d" % topn: tfr.metrics.make_ranking_metric_fn(
          tfr.metrics.RankingMetricKey.NDCG, topn=topn)
      for topn in [1, 3, 5, 10]
  })

  return metric_fns


ranker.evaluate(input_fn=lambda: input_fn(_TEST_DATA_PATH), steps=100)

上面的代码给了我 logits_mean 和其他指标。现在我需要输出文件对我的测试数据的每一行都有分数,就像我们在任何其他 ml 分类问题中得到预测输出一样。请帮忙!

【问题讨论】:

  • 您可以使用 ranker.predict 返回一个生成器,您可以对其进行迭代以创建预测,直到生成器耗尽。因此,只需通过 ranker.predict 生成器提供测试数据,然后获取这些预测并根据需要格式化输出。

标签: python tensorflow recommendation-engine ranking-functions


【解决方案1】:

不确定您是否还在此处寻找答案,但您现在可以在此处找到有关如何生成预测以进行测试的示例:https://github.com/tensorflow/ranking/blob/master/tensorflow_ranking/examples/handling_sparse_features.ipynb

它位于笔记本的最后,在“生成预测”下

【讨论】:

    猜你喜欢
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 2019-09-09
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    • 2016-05-08
    相关资源
    最近更新 更多