How to Fight Social Media Anxiety with Machine Learning

The problem

Fear of missing out, or FOMO, is “a pervasive apprehension that others might be having rewarding experiences from which one is absent”. This social anxiety is characterised by “a desire to stay continually connected with what others are doing.

FOMO is one of the reasons why we see people spend hours scrolling endlessly through their feeds. At the same time, talking from a personal perspective here, I really get confused seeing new trending topics poping up throughout the day. Most of the time, it takes a lot of effort/research to get to the bottom of the story.

Trying to keep up with all of what’s going on can be distracting, confusing, and both time, and energy consuming…

Machine Learning be like ..

The solution

Translating that to code

The Project in Action

If you search for that term on Twitter, you will find a huge number of related tweets, those tweets can be news updates, links, memes ( ͡° ͜ʖ ͡°), opinions, fake news, etc..
After crunching that data, we will get something like this as output:

Crunching data from Twitter of the term “Brexit”

Now for a person on his device that’s time and effort, but for a machine that takes what .. 2 seconds? No useless data, no spam, only relevant data.

Wait .. How can we achieve that?

  • We retrieve the data
  • We clean the data
  • We extract the relevant words
  • We create a dictionary of words used and their frequency
  • We train our model to recognise the pattern of words using a dataset of already classified comments/feedbacks.
  • We use our model to classify each tweet based on the pattern of most used words.
  • We display the cloud of most used words
  • We display the stats of opinions
  • We try to create a comprehensive overall description from the dictionary of most frequently used words!

Let’s get technical

Tweets Sentiment Classification

For this specific project, we will have 3 classes for each opinion, the features are the dictionary of words found in tweets (without stopwords, punctuation, links, etc..)

Naïve bayes classifiers can use any sort of feature (URL, email address, dictionaries, network features..)

If you want to learn more about this algorithm, check this article out.

How to train our NB model to do that?

Optional: If you have your own dataset and want to train your own model, you can use the training method. Here is an excerpt of line 111 on

Generating a Brief Description

Getting Started

Important Note

I have tried to over-simply things and include as many details as possible since I am still a beginner in ML myself. The code is self-explanatory and carefully commented. If you think there is a mistake or something is missing, please let me know in the comments.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store