From the course: Deep Learning: Getting Started

Predictions for text

From the course: Deep Learning: Getting Started

Predictions for text

- [Instructor] How do we do predictions with text? The input data needs to be preprocessed in the same way feature variables were pre-processed during training. The code for this predictions is available in section 5.4. Here we are going to do predictions for multiple inputs in a batch. Batches can be done on either structured or unstructured inputs and can actually have better resource utilization. We have two inputs, free entry to a fun contest, and, yup I will come over. We want to predict if these two SMS messages are harm or spam. We use the vectorizer model we built during training to transform them to a TFIDF vector, and then convert them to a number array. We also print the shape of the vector. To predict, we use the model to predict the probabilities of the target variables and use the Argmax function to pick the highest one. We then print the predictions for both the inputs. We finally use the label and coder to reverse transform the outputs and print the text labels. Let's run this code and review the results. The first message, free entry to fun contest, is predicted as spam, and the second entry, yup I will come over, is predicted as harm. This completes our example for text-based day planning.

Contents