title: How to predict sentiment analysis using Keras imdb dataset?
body: <p>I'm using keras to implement sentiment analysis model. I'v created the model and trained it. but now i'm not sure how to predict new data since the imdb dataset is already in vectors([22,33,4, etc...]).</p>
  
  <p>so how do i preform a prediction to a new sentence like: "i love this movie"?</p>
  
  <pre><code>from keras.datasets import imdb
  from keras.models import Sequential
  from keras.layers import Dense
  from keras.layers import LSTM, Convolution1D, Flatten, Dropout
  from keras.layers.embeddings import Embedding
  from keras.preprocessing import sequence
  from keras.callbacks import TensorBoard
  
  # Using keras to load the dataset with the top_words
  top_words = 10000
  (X_train, y_train), (X_test, y_test) = imdb.load_data(num_words=top_words)
  
  # Pad the sequence to the same length
  max_review_length = 1600
  X_train = sequence.pad_sequences(X_train, maxlen=max_review_length)
  X_test = sequence.pad_sequences(X_test, maxlen=max_review_length)
  
  # Using embedding from Keras
  embedding_vecor_length = 300
  model = Sequential()
  model.add(Embedding(top_words, embedding_vecor_length, input_length=max_review_length))
  
  # Convolutional model (3x conv, flatten, 2x dense)
  model.add(Convolution1D(64, 3, padding='same'))
  model.add(Convolution1D(32, 3, padding='same'))
  model.add(Convolution1D(16, 3, padding='same'))
  model.add(Flatten())
  model.add(Dropout(0.2))
  model.add(Dense(180,activation='sigmoid'))
  model.add(Dropout(0.2))
  model.add(Dense(1,activation='sigmoid'))
  
  # Log to tensorboard
  tensorBoardCallback = TensorBoard(log_dir='./logs', write_graph=True)
  model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  
  model.fit(X_train, y_train, epochs=3, callbacks=[tensorBoardCallback], batch_size=64)
  
  # Evaluation on the test set
  scores = model.evaluate(X_test, y_test, verbose=0)
  print("Accuracy: %.2f%%" % (scores[1]*100))
  
  model.save("trained_demo.h5")
  </code></pre>