O'Reilly logo

Deep Learning Cookbook by Douwe Osinga

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Suggesting Emojis

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

7.1 Building a Simple Sentiment Classifier

Problem

How can you determine the sentiment expressed in a piece of text?

Solution

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required