Twitter Analytics using Mathematica
Twitter has been just about everywhere lately. As its popularity continues to grow, how do you keep track of the expanding list of friends and followers? As more companies are using Twitter to promote their products, good tools are necessary to manage hundreds or thousands of contacts and analyze their Twitter social graph .
Twitter has an open api, and Mathematica is the best analytical tool out there. Mathematica’s image manipulation capability also makes it a very nice data visualizer. So let us plug Twitter in Mathematica, and play with the data.
In the examples, let’s use Wolfram_Alpha (my personal twitter data is not very interesting). WolframAlpha has just recently launched, and they have been actively posting news and updates with Twitter. Let’s first look at W|A’s recent tweets.
In[329]:=

In[331]:=
![]()
So here we import the user’s timeline, and transform the list of XMLObjects to a list of rules from attribute to value.
Now we can visualize the time and frequency of the user’s recent tweets in a timeline, where x-axis is the date and y-axis is the number of seconds during the day (eg. 30000s = 8:20 am).
In[334]:=
![]()
Out[336]=

After seeing Mathematica’s visualizations, we want to do analysis and play around with the friendship data. Let us load up the users Wolfram Alpha is following,
In[338]:=
![]()
Out[338]=

In[339]:=
![]()
Out[339]=
![]()
All friends’ profile data are loaded, and the size is consistent with the number on the website. To apply a filter, say look for the friends with screen name begins with “a”,
In[340]:=
![]()
Out[341]=
![]()
And put the name to the profile picture.
In[342]:=
![]()
Out[342]=

One of most important features on Wolfram Alpha is performing arithmetic and comparisons on objects. For example, try comparing between three stocks GOOG, AAPL and MSFT, or add up your nutrition value of a meal at McDonald’s. I also want to compare between a list of friends, which can be easily done by:
In[343]:=
![]()
Out[343]=

Now I’m interested to find out which friends have most followers, by sorting the friends with follower counts, and take top 20 results.
In[344]:=
![]()
Visualize of the results with a directed graph. An arrow from user A to user B indicates that user A is following user B.
In[345]:=
![]()
Out[345]=

We can also visualize the same list of users in a bubble plot. X - axis is number of followings, y - axis is number of followers, and the size of the image is determined by the ratio of followers / friends (ie, image is bigger if number of followers / number of friends is higher).
In[346]:=
![]()
Out[346]=

Because of Wolfram Alpha, most programmers probably have seen what Mathematica can do. Its applications are endless: I have been using it to analyze stock arbitrage opportunities, and we are also interested in analyzing the way people read comics on iPhone.
The examples above were over spare hours (or minutes) over last few nights just for fun. If anyone has any suggestions about Twitter / Mathematica, let me know (@kevenlin). This blog post from WolframBlog will also show you other cool things such as tweet from Mathematica.
-
sillygwailo reblogged this from lambdalog
-
gtokio reblogged this from lambdalog
-
lambdalog posted this