In this chapter we’ll build a model to suggest emojis given a small piece of text. We’ll start by developing a simple sentiment classifier based on a public set of tweets labeled with various sentiments, like happiness, love, surprise, etc. We’ll first try a Bayesian classifier to get an idea of the baseline performance and take a look at what this classifier can learn. We’ll then switch to a convolutional network and look at various ways to tune this classifier.
Next we’ll look at how we can harvest tweets using the Twitter API ourselves, and then we’ll apply the convolutional model from Recipe 7.3 before moving on to a word-level model. We’ll then construct and apply a recurrent word-level network, and compare the three different models.
Finally, we’ll combine all three models into an ensemble model that outperforms any of the three.
The final model does a very decent job and just needs to be rolled into a mobile app!
The code for this chapter can be found in these notebooks:
07.1 Text Classification 07.2 Emoji Suggestions 07.3 Tweet Embeddings
How can you determine the sentiment expressed in a piece of text?
Find a dataset consisting of sentences where the sentiment is labeled and run a simple classifier over them.
Before trying something complicated, it is a good idea to first try the simplest thing we can think of on a dataset that is readily available. In this case we’ll try to build ...