<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>OUseful.Info, the blog... &#187; Social Interest Positioning &#8211; Visualising Facebook Friends&#8217; Likes With Data Grabbed Using Google Refine</title>
	<atom:link href="http://blog.ouseful.info/2012/01/04/social-interest-positioning-visualising-facebook-friends-likes/feed/?withoutcomments=1" rel="self" type="application/rss+xml" />
	<link>http://blog.ouseful.info</link>
	<description>Trying to find useful things to do with emerging technologies in open education</description>
	<lastBuildDate>Thu, 23 May 2013 09:43:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.ouseful.info' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>OUseful.Info, the blog... &#187; Social Interest Positioning &#8211; Visualising Facebook Friends&#8217; Likes With Data Grabbed Using Google Refine</title>
		<link>http://blog.ouseful.info</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.ouseful.info/osd.xml" title="OUseful.Info, the blog..." />
	<atom:link rel='hub' href='http://blog.ouseful.info/?pushpress=hub'/>
		<item>
		<title>Social Interest Positioning &#8211; Visualising Facebook Friends&#8217; Likes With Data Grabbed Using Google Refine</title>
		<link>http://blog.ouseful.info/2012/01/04/social-interest-positioning-visualising-facebook-friends-likes/</link>
		<comments>http://blog.ouseful.info/2012/01/04/social-interest-positioning-visualising-facebook-friends-likes/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 11:06:45 +0000</pubDate>
		<dc:creator>Tony Hirst</dc:creator>
				<category><![CDATA[Analytics]]></category>
		<category><![CDATA[Data]]></category>
		<category><![CDATA[onlinejournalismblog]]></category>
		<category><![CDATA[Tutorial]]></category>
		<category><![CDATA[Uncourse]]></category>
		<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Google Refine]]></category>
		<category><![CDATA[grefine]]></category>

		<guid isPermaLink="false">http://blog.ouseful.info/?p=6729</guid>
		<description><![CDATA[What do my Facebook friends have in common in terms of the things they have Liked, or in terms of their music or movie preferences? (And does this say anything about me?!) Here&#8217;s a recipe for visualising that data&#8230; After discovering via Martin Hawksey that the recent (December, 2011) 2.5 release of Google Refine allows [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=6729&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>What do my Facebook friends have in common in terms of the things they have Liked, or in terms of their music or movie preferences? (And does this say anything about me?!) Here&#8217;s a recipe for visualising that data&#8230;</p>
<p>After discovering <a href="http://mashe.hawksey.info/2012/01/free-and-rebuild-the-tweets-export-twapperkeeper-archives-using-google-refine/">via Martin Hawksey</a> that the recent (December, 2011) <a href="http://code.google.com/p/google-refine/wiki/ChangesFor2p5">2.5 release of Google Refine</a> allows you to import JSON and XML feeds to bootstrap a new project, I wondered whether it would be able to pull in data from the Facebook API if I was logged in to Facebook (Google Refine does run in the browser after all&#8230;)</p>
<p>Looking through the <a href="http://developers.facebook.com/docs/reference/api/">Facebook API documentation</a> whilst logged in to Facebook, it&#8217;s easy enough to find exemplar links to things like your friends list (<em><a href="https://graph.facebook.com/" rel="nofollow">https://graph.facebook.com/</a><strong>me</strong>/friends?access_token=A_LONG_JUMBLE_OF_LETTERS</em>) or the list of likes someone has made (<em><a href="https://graph.facebook.com/" rel="nofollow">https://graph.facebook.com/</a><strong>me</strong>/likes?access_token=A_LONG_JUMBLE_OF_LETTERS</em>); replacing <em>me</em> with the Facebook ID of one of your friends should pull down a list of their friends, or likes, etc.</p>
<p>(Note that validity of the access token is time limited, so you can&#8217;t grab a copy of the access token and hope to use the same one day after day.)</p>
<p>Grabbing the link to your friends on Facebook is simply a case of opening a new project, choosing to <em>get the data from a Web Address</em>, and then pasting in the friends list URL:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6633972841/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7025/6633972841_5909bf4a46.jpg" width="500" height="152" alt="Google Refine - import Facebook friends list" /></a></p>
<p>Click on next, and Google Refine will download the data, which you can then parse as a JSON file, and from which you can identify individual record types:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6633985963/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7141/6633985963_8669f64d93.jpg" width="500" height="498" alt="Google Refine - import Facebook friends" /></a></p>
<p>If you click the highlighted selection, you should see the data that will be used to create your project:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6633996055/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7145/6633996055_c739a3309c.jpg" width="500" height="158" alt="Google Refine - click to view the data" /></a></p>
<p>You can now click on <em>Create Project</em> to start working on the data &#8211; the first thing I do is tidy up the column names:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6634000149/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7165/6634000149_d6f09e94d2.jpg" width="500" height="442" alt="Google Refine - rename columns" /></a></p>
<p>We can now work some magic &#8211; such as pulling in the Likes our friends have made. To do this, we need to create the URL for each friend&#8217;s Likes using their Facebook ID, and then pull the data down. We can use Google Refine to harvest this data for us by creating a new column containing the data pulled in from a URL built around the value of each cell in another column:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6634005421/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7016/6634005421_54812070ff.jpg" width="500" height="465" alt="Google Refine - new column from URL" /></a></p>
<p>The Likes URL has the form <em><a href="https://graph.facebook.com/" rel="nofollow">https://graph.facebook.com/</a><strong>me</strong>/likes?access_token=A_LONG_JUMBLE_OF_LETTERS</em> which we&#8217;ll tinker with as follows:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6634026767/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7152/6634026767_972c2bcf71.jpg" width="500" height="388" alt="Google Refine - crafting URLs for new column creation" /></a></p>
<p>The throttle control tells Refine how often to make each call. I set this to 500ms (that is, half a second), so it takes a few minutes to pull in my couple of hundred or so friends (I don&#8217;t use Facebook a lot;-). I&#8217;m not sure what limit the Facebook API is happy with (if you hit it too fast (i.e. set the throttle time too low), you may find the Facebook API stops returning data to you for a cooling down period&#8230;)?</p>
<p>Having imported the data, you should find a new column:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6634040291/" title="Photo Sharing"><img src="http://farm8.staticflickr.com/7175/6634040291_0c306768b5.jpg" width="500" height="226" alt="Google Refine - new data imported" /></a></p>
<p>At this point, it is possible to generate a new column from each of the records/Likes in the imported data&#8230; in theory (or maybe not..). I found this caused Refine to hang though, so instead I exprted the data using the default <em>Templating&#8230;</em> export format, which produces some sort of JSON output&#8230;</p>
<p>I then used this Python script to generate a two column data file where each row contained a (new) unique identifier for each friend and the name of one of their likes:</p>
<pre class="brush: python; title: ; notranslate">import simplejson,csv

writer=csv.writer(open('fbliketest.csv','wb+'),quoting=csv.QUOTE_ALL)

fn='my-fb-friends-likes.txt'

data = simplejson.load(open(fn,'r'))
id=0
for d in data['rows']:
	id=id+1
	#'interests' is the column name containing the Likes data
	interests=simplejson.loads(d['interests'])
	for i in interests['data']:
		print str(id),i['name'],i['category']
		writer.writerow([str(id),i['name'].encode('ascii','ignore')])
</pre>
<p>[I think this R script, in answer to a related @mhawksey Stack Overflow question, also does the trick: <a href="http://stackoverflow.com/questions/9105597/r-building-a-list-from-matching-values-in-a-data-frame">R: Building a list from matching values in a data.frame</a>]</p>
<p>I could then import this data into Gephi and use it to generate a network diagram of what they commonly liked:</p>
<p><a href="http://www.flickr.com/photos/psychemedia/6629870307/" title="Sketching common likes amongst my facebook friends by psychemedia, on Flickr"><img src="http://farm8.staticflickr.com/7007/6629870307_fc9a948788_z.jpg" width="640" height="444" alt="Sketching common likes amongst my facebook friends"></a></p>
<p>Rather than returning Likes, I could equally have pulled back lists of the movies, music or books they like, their own friends lists (permissions settings allowing), etc etc, and then generated friends&#8217; interest maps on that basis.</p>
<p>[See also: <a href="http://blog.ouseful.info/2010/04/16/getting-started-with-gephi-network-visualisation-app-my-facebook-network-part-i/">Getting Started With The Gephi Network Visualisation App – My Facebook Network, Part I</a> and <a href="http://blog.ouseful.info/2011/10/16/so-where-am-i-socially-situated-on-google/">how to visualise Google+ networks</a>]</p>
<p>PS dropping out of Google Refine and into a Python script is a bit clunky, I have to admit. What would be nice would be to be able to do something like a &#8220;create new rows with new column from column&#8221; pattern that would let you set up an iterator through the contents of each of the cells in the column you want to generate the new column from, and for each pass of the iterator: 1) duplicate the original data row to create a new row; 2) add a new column; 3) populate the cell with the contents of the current iteration state. Or something like that&#8230;</p>
<p>PPS Related to the PS request, there is a sort of related feature in the 2.5 release of Google Refine that lets you merge data from across rows with a common key into a newly shaped data set: <a href="http://code.google.com/p/google-refine/source/detail?r=2356">Key/value Columnize</a>. Seeing this, it got me wondering what a fusion of Google Refine and RStudio might be like (or even just R support within Google Refine?)</p>
<p>PPPS <a href="http://translate.google.com/translate?hl=en&amp;sl=fi&amp;u=http://verkostoanatomia.wordpress.com/2012/02/10/kansanedustajat-facebookissa-kuka-on-kenenkin-kaveri/">this could be interesting</a> &#8211; looks like you can test to see if a friendship exists given two Facebook user IDs.</p>
<p>PPPPS This paper in PNAS &#8211; <a href="http://www.pnas.org/content/early/2013/03/06/1218772110.full.pdf">Private traits and attributes are predictable from digital records of human behavior</a> &#8211; by Kosinski et. al suggests it&#8217;s possible to profile people based on their Likes. It would be interesting to compare how robust that profiling is, compared to profiles based on the common Likes of a person&#8217;s followers, or the common likes of folk in the same Facebook groups as an individual?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/ouseful.wordpress.com/6729/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/ouseful.wordpress.com/6729/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.ouseful.info&#038;blog=325417&#038;post=6729&#038;subd=ouseful&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.ouseful.info/2012/01/04/social-interest-positioning-visualising-facebook-friends-likes/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/abbd9f90565ce9ae4d065d93a81d8c03?s=96&#38;d=http%3A%2F%2F1.gravatar.com%2Favatar%2Fad516503a11cd5ca435acc9bb6523536%3Fs%3D96" medium="image">
			<media:title type="html">Tony Hirst</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7025/6633972841_5909bf4a46.jpg" medium="image">
			<media:title type="html">Google Refine - import Facebook friends list</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7141/6633985963_8669f64d93.jpg" medium="image">
			<media:title type="html">Google Refine - import Facebook friends</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7145/6633996055_c739a3309c.jpg" medium="image">
			<media:title type="html">Google Refine - click to view the data</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7165/6634000149_d6f09e94d2.jpg" medium="image">
			<media:title type="html">Google Refine - rename columns</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7016/6634005421_54812070ff.jpg" medium="image">
			<media:title type="html">Google Refine - new column from URL</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7152/6634026767_972c2bcf71.jpg" medium="image">
			<media:title type="html">Google Refine - crafting URLs for new column creation</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7175/6634040291_0c306768b5.jpg" medium="image">
			<media:title type="html">Google Refine - new data imported</media:title>
		</media:content>

		<media:content url="http://farm8.staticflickr.com/7007/6629870307_fc9a948788_z.jpg" medium="image">
			<media:title type="html">Sketching common likes amongst my facebook friends</media:title>
		</media:content>
	</item>
	</channel>
</rss>
