user2986503
user2986503

Reputation: 27

Show percentage after prediction in Keras

I've trained model with Keras which predicts tags according to post. After training it loops over 10 test posts and predicts tag. I also need to show accuracy of prediction for every post but I don't know what to do... This is sample of the code.I would appreciate your help.

for i in range(10):
prediction = loaded_model.predict(np.array([x_test[i]]))
predicted_label = text_labels[np.argmax(prediction)]
print(test_posts.iloc[i][:50], "...")
print('Actual label:' + test_tags.iloc[i])
print("Predicted label: " + predicted_label + "\n")

Upvotes: 0

Views: 1812

Answers (1)

josepdecid
josepdecid

Reputation: 1857

I've done a little test with some categories, [0, 1, ..., 9]. The function predict returns an array for the probability of each class. So that, you could just print max(prediction) as long as it's category and whatever you need.

Upvotes: 5

Related Questions