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

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -