Wednesday, August 21, 2013

Create a tag cloud of tweets using Python

Here I will show you a simple code (the full version is on GitHub: to create a tagcloud based on the content of tweets talking about a given query and save it as a png.

Retrieving tweets using Python

Many of you have asked how to retrieve tweets from the Twitter API using Python. Well... it's extremely simple! First of all, if you still don't have one, you have to open a Twitter developer account and obtain your "secrets" (as explained here: that you will later use to authenticate.

Sunday, June 16, 2013

How to: visualize the network of your friends on Facebook

Here I will teach you how to visualize the network of mutual friendship among your Facebook friends using a simple online tool called FriendsGraph.

Friday, May 24, 2013

How to: Visualize Tweets on a Map using Java and Gephi

Some people are asking me how to visualize tweets related to a given topic on a map. In this tutorial you will learn how to do it using Java (to collect the tweets) and Gephi (to visualize them).

Monday, May 20, 2013

Language Communities and Information Flow on Twitter

Inspired by an awesome visualization by Eric Fischer, I decided to create a map of tweets which represents the language communities and the information flow on Twitter. Each tweet is represented on the map as a point whose color is determined by the language settings of its creator. The arcs represent retweets; in this way it was possible to visualize how the information flows between the different language communities on Twitter.

To achieve this result I donwloaded geolocated tweets for 4 days from the Twitter  Streaming API. The total number of retrieved tweets is 247850 (4632 of which are retweets). Gephi was used to produce the final visualization.

From this analysis, some interesting aspects emerge:

Thursday, May 16, 2013

How to: Sentiment Analysis of Tweets using Java

Since it is a quite interesting topic, I will describe a simple but accurate process for the sentiment analysis of tweets using Java, based on the use of two libraries: Twitter4J (to collect tweets) and LingPipe (to classify their sentiment).

If you want to easily download the code used in this tutorial, you can easily download it from GitHub here:

Phase 1 - Train the classifier

In this phase you will learn how to train a sentiment classifier and save it as a .txt file for later use. If you don't want to train your own classifier you can simply download one from here (it has been trained on random tweets written in English and can distinguish between positive, negative and neutral tweets with an accuracy of  approximately 75%) and skip to the next phase.