Skip to content

Instantly share code, notes, and snippets.

@craftzdog
Created September 2, 2015 11:38
Show Gist options
  • Save craftzdog/301faab905b579e229d1 to your computer and use it in GitHub Desktop.
Save craftzdog/301faab905b579e229d1 to your computer and use it in GitHub Desktop.
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys, numpy
categories = numpy.loadtxt(sys.argv[1], str, delimiter="\t")
scores = numpy.load(sys.argv[2])
top_k = 10
prediction = zip(scores[0].tolist(), categories)
prediction.sort(cmp=lambda x, y: cmp(x[0], y[0]), reverse=True)
for rank, (score, name) in enumerate(prediction[:top_k], start=1):
print('#%d | %s | %4.1f%%' % (rank, name, score))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment