Using Artificial Intelligence to Understand Emotions in Tweets

Allison Colyer

Allison Colyer

August 27 • 3 Min Read

Hello, internet! Meet Feelsbot. Feelsbot tries to understand how humans are feeling by reading their tweets. Feelsbot can analyze Tweets of any geographical location or any public Twitter profile.

gif of feelsbot

In this blog, I’ll discuss how Feelsbot uses artificial intelligence to analyze emotional sentiment in Tweets.

What is Artificial Intelligence and Machine Learning?

Artificial Intelligence (AI) seems to be all over the place these days, but what exactly is it? Feelsbot, which uses AI to understand tweets, is a great example to help answer this question.

AI is a field of computer science dedicated to creating machines that can make intelligent decisions. You can think of artificial intelligence as a goal. We can reach that goal through machine learning. Machine learning is a way to teach machines how to make predictions or decisions without being explicitly programmed.

Machine learning models are said to learn because instead of being programmed to do things, they are trained. A model is trained through being shown lots of example data points and looking for patterns in the examples. Once identified, these patterns will be used to make decisions about new pieces of data.

Feelsbot uses a machine learning model created by IBM that categorizes text as being either joyful, sad, angry, disgusted, or fearful. This model was trained to detect emotion by being shown lots of examples of joyful, sad, angry, disgusted and fearful text. The patterns the model detected may involve keywords, such as “cry” or “cheer”, or they may involve the number of words in each sentence. Whatever the patterns are, they all come together to form the machine learning model.

Natural language processing is a subset of AI that aims to understand human language. The machine learning model that powers Feelsbot can also be called natural language processing.

Inspiration for Creating Feelsbot

There are a few reasons why I decided to create Feelsbot. First off, I was inspired by how easy it is to hop in and use some of the machine learning APIs from IBM and Google. Additionally, I wanted to create a software project to help people better understand how AI works.

Feelsbot highlights a couple of important things about AI and natural language processing.

  • Many machine learning models have a rather simplistic view of emotion, and can’t pick up on subtle things, such as sarcasm.
  • Sometimes figures of speech can throw off the model, for example, “I’m so happy I could cry” is detected as sad with a 65% confidence.

Although Feelsbot is not perfect, it’s more accurate than you might expect! I am often surprised by how well it can categorize more ambiguous tweets. Try it out to see for yourself.

image of cartoon robot crying, celebrating and short-circuiting

Note: Tweets are short and often use slang which doesn’t always work well with a machine learning model trained with regular text excerpts. For this project, I did not train my own model, but it would be interesting to create a machine learning model that is trained using only tweets.

How Feelsbot Finds and Categorizes Tweets

As mentioned before, Feelsbot is using a machine learning model from IBM to analyze emotions in tweets. Using this model, Feelsbot put tweets into five categories: joy, sadness, anger, fear, and disgust. This model only works in English, limiting the number of tweets Feelsbot can analyze. Each tweet receives a score, called a confidence score, of how strongly it matches one of those categories. Feelsbot puts tweets that have a confidence score higher than 65% into each category. Once the tweets have been categorized, the joy meter is calculated as the percentage of joyful tweets versus every other emotion.

When using the map, Feelsbot uses Twitter’s API to fetch the last 100 tweets that are geotagged near the location entered. If there are not many recent geotagged tweets near that location, Twitter fetches tweets of users whose profile locations are nearby. When analyzing tweets by a specific Twitter account, Feelsbot fetches the last 150 tweets by that account. Twitter profiles need to be public for Feelsbot to work.

What’s next for Feelsbot?

Check out Feelsbot and let me know what you think! By request, a hashtag search is currently in the works, so keep your eyes peeled for that update.


  • Big thanks to Novvum for supporting the development of Feelsbot.
  • Feelsbot was created by Allison Colyer.
  • Robot drawings were created by Ruby Ríos.

artificial intelligence machine learningAI