Project completed and this blog text edited by: Matteo Tosi and Andrea Fiore
Our project’s aim is to calculate affinity between Facebook users using the attributes location and hometown and its variation after inferring these attributes.
We wrote a python program that infers an user’s location data by analyzing the data of his friends.
We used the library igraph for python to represent the Facebook graph.
First of all, we executed the following query to retrieve from the table rawData the referrer users
SELECT distinct referrer FROM rawData.
Then for each referrer we executed the query (taken from the python code)
(“SELECT user,dataBare from rawData WHERE link=referrer AND referrer= %s”, (user))
to find the user referred by each user in the result set of the first query. We used the result of this query to find the EGO NETWORK for each one of the referrer users.
The attribute dataBare has been parsed as a json string to access the attributes contained in the string by key names.
The we calculated affinity for the attributes location and hometown; we made as below:
for each attribute analyzed the program calculated the value S which represents the value of fraction for which users share the same value for the attribute;
S = number_of_couples / total_number_of_attributes
Then for each value of the attribute was calculated the value Ea defined as below:
Affinity has been calculated as A = S/E.
The last goal of our work was to infer location and hometown attributes for those users who didn’t have these attributes.
For both the attributes location and hometown we had to proceed as below:
- first of all the program detected the most common value for the attributes hometown and location in the network representing the social network
- then the program found the users who didn’t insert the attribute in their personal location information
- The program assigned the most common value for each attribute to those users who didn’ specified a value to the attribute analized
- The program calculated the affinity after inferring the missing attributes, using the same operations described before.