2

I am working in imdb dataset on reviews, when i want to predict the outcome of the user given input using the model.predict method in tensorflow it gives an array. How to interpret the results from that array?

string = str(input())
new_string = token.texts_to_sequences(string)
padded_new_string = pad_sequences(new_string,maxlen = 120, truncating = 'post')
print(model.predict(padded_new_string))

Also i used binary classification using sigmoid

model = tf.keras.Sequential([
    tf.keras.layers.Embedding(10000,16,input_length = 120),
    tf.keras.layers.Flatten(),
    tf.keras.layers.Dense(12,activation = 'relu'),
    tf.keras.layers.Dense(6,activation = 'relu'),
    tf.keras.layers.Dense(1,activation = 'sigmoid')
    ])        

Any help will be helpful

Arihant Kamdar
  • 124
  • 1
  • 7

1 Answers1

1

If I'm not mistaken model.predict returns numpy array for each corresponding prediction of the y_test. To interpret the values you could use evaluate method to find the accuracy of your model

score = model.evaluate(x_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
Ahmet
  • 7,527
  • 3
  • 23
  • 47
  • What about the other values in the array ? they must also tell something about the model. – Arihant Kamdar Jul 28 '20 at 05:05
  • Maybe you should look at the [link](https://stackoverflow.com/questions/37891954/keras-how-do-i-predict-after-i-trained-a-model) The fact is I can't tell precisely what is the output of your predcitions, since I can't test your code. I believe you should look at your `y_test` and `y_pred` results to get a meaningful interpretation. – Ahmet Jul 28 '20 at 05:23