1

I am not able to get the scores as output in a file for each row from the scoring function.

I am using a scoring function to rank my documents in recommendation engine with Python in Jupyter notebook. I am using below code to evaluate on my test data -

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)

The above code is giving me logits_mean and other metric. Now I need the output file having score for each row of my test data like we get prediction output in any other ml classification problem. Please help!

ComplicatedPhenomenon
  • 4,055
  • 2
  • 18
  • 45
Abhishek V
  • 141
  • 1
  • 7
  • You can use ranker.predict which returns a generator, which you can iterate over to create predictions, till the generator is exhausted. So simply feed the test data through the ranker.predict generator and then take those predictions and format your output however you would like to. – colby-ham Nov 05 '19 at 23:13

1 Answers1

1

Not sure you're still looking for an answer here, but you can now find an example on how to generate predictions for testing here: https://github.com/tensorflow/ranking/blob/master/tensorflow_ranking/examples/handling_sparse_features.ipynb

It's at the very end of the notebook, under 'Generating Predictions'

heidemarie
  • 115
  • 5