Tracking Brand Sentiment
with the Tweepy API
By Philip Harman
​
​Understanding global brand perception helps companies know where to focus their PR efforts. Below, I've demonstrated how this information can be obtained by analysing Twitter feeds (not mobile-friendly).
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
How does this work?
I set up a stream listener using the Tweepy API. In just 48 hours, I was able to gather over 12,000 Tweets related to four brands of my choosing (the names of which I've redacted for this example).
​
Next, I extracted sentiment for each Tweet on a scale of -5 to 5 using vaderSentiment. This package achieves a classification accuracy score of 84%, and is specifically made for social media (it even takes things like emojis into consideration). Finally, I used GeoPy to extract coordinates of these Tweets for mapping, and built the dashboard above using Dash.
​
For the source code of this project, check out my GitHub.
​