How to analyze Twitter data

min read

Our Twitter Analysis Recipe

Learn how to analyze tweets in a few simple lines of code!

Analyzing Twitter social media data allows companies to use clustering to find themes and trends from tweets and competitors.

Drill down and find specific themes in tweets and identify what content is driving Twitter engagement.

Below is a Google Colab notebook on how to create your own twitter analysis application:

Click here to start building in Colab!

This recipe aims to walk you through:

  • How to scrape tweets using Twint
  • How to vectorize your tweets (turning unstructured text data into a data format useful for interpretation by models)
  • How to cluster your tweets with Relevance AI

Prerequisites

  • Twitter Username (no account needed!)

Use Cases

  • How to optimize my tweets for likes
  • Discover underlying themes in popular tweets
  • Discover Twitter trends
  • Twitter analytics
  • Top twitter trends

Tutorial

Firstly, open the Colab notebook link above.

Step 0 – Fill in your Twitter username.

Step 1 – Then run the cell below it. In the top-left corner, press the play button.

Step 2 – Navigate to the top toolbar, hover over runtime, then hit Refresh and run all.

Step 3: Wait. The hard part is done! Wait approximately 2 minutes and you should see a dashboard link. In some cases, the Colab may hang. In those situations, simply navigate to cloud.relevance.ai and find your dashboard.

Your dashboard will look a lot like this:

Step 4: After building your dashboard, you can navigate to your dataset. On the bottom left, underneath “Apps”, you can see “Clusters”. Be sure to click that and access your dashboard.

Step 5: Have fun exploring your twitter themes and dashboard! Be sure to try out all the different modes and explore your tweets in-depth!

Common Questions And Answers

1 – How can I interpret Twitter account data?

Focusing on the Twitter-specific language, retweets are a form of engagement and refers to when other people re-share your content.

2 – What is the advantage of this method compared to analysing via R or SQL?

R, SQL are great programming languages and can definitely be used to analyse these tweets. Relevance AI is primarily written in Python due to a rich machine learning ecosystem, from which we allow users to build highly interactive and insightful applications with drilldown and information analysis.

3- Are there any potential issues with scraping profile data from Twitter?

From a technical standpoint, Twint only allows you to scrape the last 3200 tweets.

4- What specific points of data will I be able to scrape?

We use Twint as our intelligence tool which means you can scrape users, topics, hashtags, trends, tweets, followers, retweets, counts, profiles. We recommend consulting the original github repository here for more information.

If you have feedback, we would love to hear it! Join our Slack community or email us at support@relevance.ai so we can assist you with using our dashboard if required.

This is just a quick tutorial on Relevance AI, there are many more applications that is possible such as zero-shot based labelling, recommendations, anomaly detection, projector and more:

How to analyze Twitter data
Jacky Wong
March 7, 2022
Want to mine external data sources for business and product strategy?

Find insights in unstructured data with Relevance AI's Clustering platform.