python - Get class with highest score -
i use following code predictions.
for node_id in top_k: score = predictions[0][node_id] human_string = label_lines[node_id] print('%s (score = %.5f)' % (human_string, score))
the above code prints predictions scores classes. however, how label highest score?
here's solutions using max
score, key = max((v, k) k, v in predictions[0].items()) print('{} (score = {:.5f})'.format(label_lines[key], score))
Comments
Post a Comment