Analyzing the sentiment in specific sentences
Now, let's take a look at some predicted samples from the test set:
import tensorflow as tf tf.get_logger().setLevel('ERROR') def get_sentiment(val): return "Positive" if val == 1 else "Negative" for i in range(10): print(x_test[i]) print("label: %s, prediction: %s" % (get_sentiment(y_test[i][0]), get_sentiment(clf.predict(x_test[i:i+1])[0][0])))
Here is the output of the preceding code:
As you can see, the model predictions match every label for the first 10 samples in the test dataset.