Reputation: 27
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
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