nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook

Home Page:https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Having problem in predicting the message

padmaja9 opened this issue · comments

I'm really a beginner with tensor flow and in all of this field.i was asked to do a spam detection using Recurrent Neural Network.I took a reference of your code.
I went through this code https://github.com/nfmcclure/tensorflow_cookbook/blob/master/09_Recurrent_Neural_Networks/02_Implementing_RNN_for_Spam_Prediction/02_implementing_rnn.ipynb
it is working fine.but i didn't understand where to give our own message as input to predict whether it is spam or ham. could you please help me out in finding the solution for this

commented

Hi @padmaja9 ,
Thanks for the message!

I haven't gotten around to adding an evaluation part for new data at the end of the notebook. It's a great idea and I will see if I can do that this weekend.

If you can't wait, here's what it would entail:

  1. Have your input text cleaned with the eval_data = clean_text(eval_text) function.
  2. Process cleaned text into numerical vectors via the vocab_processor like the line: eval_processed = np.array(list(vocab_processor.fit_transform(eval_data))) that is in the code.
  3. Get the output_logits, which are the model output values before the softmax via something like: eval_output = sess.run(logits_out, feed_dict={x_data: eval_processed, dropout_keep_prob: 1.0})

Then the prediction is the np.argmax(eval_output). I'll see if I can update the jupyter notebook this weekend.

Hi @nfmcclure ,
Thanks for the response.
I added the evaluation part to my code but i'm unable to get the prediction correctly.It would be great if you could add this evaluation part this weekend.

commented

Hi @padmaja9 ,
Please checkout the bottom of the jupyter notebook:
https://github.com/nfmcclure/tensorflow_cookbook/blob/master/09_Recurrent_Neural_Networks/02_Implementing_RNN_for_Spam_Prediction/02_implementing_rnn.ipynb

I've added some code to do predictions on new texts using the model that is in memory. I hope that helps.

I'm going to close this issue. If you have further questions, feel free to re open.