Created
September 2, 2015 11:38
-
-
Save craftzdog/301faab905b579e229d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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