matrix - How to tell python to not round the numbers? -
i'm using python , have matrix 1º column has names , 2º column has confidence. matrix called top_list. want transform each column in 1 list did as:
classes = matrix(top_list).transpose()[0].geta()[0] # top class name probs = matrix(top_list).transpose()[1].geta()[0] # confidence
the problem confidences appear like this numbers rounded.
how can keep decimal places?
update:
my code here:
classes = matrix(top_list).transpose()[0].geta()[0] # top class name classes = np.delete(classes, [0, 1, 2, 3, 4]) # delete first 5 elements probs = matrix(top_list).transpose()[1].geta()[0] # top class probability probs = np.delete(probs, [0, 1, 2, 3, 4]) # delete first 5 elements #print classes #print probs f = open('top_5_class_labels.txt', 'a') f.write('\n\n\n') f.write('top 5 class labels [final solution] \n\n') f.write("{: <50} {: <15} \n\n".format('predicted classes', 'probability')) x in range(0, 5): idx = max(range(len(probs)), key=lambda i: probs[i]) #print classes[idx] #print probs[idx] f.write("{: <50} {: <15} \n".format(classes[idx], probs[idx])) probs[idx] = 0 f.close()
Comments
Post a Comment