<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
     xmlns:atom="http://www.w3.org/2005/Atom"
     xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:wfw="http://wellformedweb.org/CommentAPI/"
     >
  <channel>
    <title>brain of mat kelcey</title>
    <link>http://matpalm.com/blog</link>
    <description>thoughts from a data scientist wannabe</description>
    <generator>Blogofile</generator>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>e10.6 community detection for my twitter network</title>
      <link>http://matpalm.com/blog/2010/04/04/375/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[twitter]]></category>
      <category><![CDATA[betweenness]]></category>
      <category><![CDATA[social network]]></category>
      <category><![CDATA[graph]]></category>
      <guid>http://matpalm.com/blog/?p=375</guid>
      <description>e10.6 community detection for my twitter network</description>
      <content:encoded><![CDATA[<p>last night i applied my network decomposition algorithm to a graph of some of the people near me in twitter.</p>
<p>first i build a friend graph for 100 people 'around' me (taken from a <a href="http://matpalm.com/blog/2009/09/29/e10-3-twitter-crawl-progress/">crawl</a> i did last year). by 'friend' i mean that if alice follows bob then bob also follows alice.</p>
<p>here the graph, some things to note though; it was an unfinished crawl (can a crawl of twitter EVER be finished) and was done october last year so is a bit out of date.</p>
<p><a href="/blog/imgs/2010/04/friends.jpg"><img class="aligncenter size-large wp-image-377" title="friends" src="/blog/imgs/2010/04/friends-1024x204.jpg" alt="friends" width="1024" height="204" /></a><!--more--></p>
<p>and here is the dendrogram decomposition</p>
<p><a href="/blog/imgs/2010/04/dendrogram.vert_.600.jpg"><img class="aligncenter size-full wp-image-391" title="dendrogram.vert.600" src="/blog/imgs/2010/04/dendrogram.vert_.600.jpg" alt="dendrogram.vert.600" width="600" height="1500" /></a>some interesting clusterings come out..</p>
<p>right at the bottom we have a small clique (ie everyone following everyone else) of people i've known from when i was in <em>sydney</em></p>
<p><a href="/blog/imgs/2010/04/sydney.nokia_.jpg"><img class="aligncenter size-full wp-image-387" title="sydney.nokia" src="/blog/imgs/2010/04/sydney.nokia_.jpg" alt="sydney.nokia" width="185" height="98" /></a></p>
<p>this small group connects to the group i'm in; <a href="http://twitter.com/tinybuddha">tinybuddha</a> down to <a href="http://twitter.com/evanbottcher">evanbottcher</a>; which roughly describes the group of people i've met in <em>melbourne</em>.</p>
<p>the order of the single breakaways in the melbourne group is pretty arbitrary. i get quite different ordering if i run the decomposition multiple times due to the random tie breaking involved. i could either run the decomposition multiple times and work out some kind of averaging or choose another more granular way of deciding how to break ties.</p>
<p>the next connector after <em>syndey</em> and <em>melbourne</em> are unified is <a href="http://twitter.com/deanemorrow">deanemorrow</a> a coworker when i was at <a href="http://twitter.com/distra">distra</a>. this one sticks out for me as being the biggest flaw in the clustering since it would have made more sense to have him placed near distra at the bottom.</p>
<p>another interesting clique is near me..</p>
<p><a href="/blog/imgs/2010/04/twers.jpg"><img class="aligncenter size-full wp-image-393" title="twers" src="/blog/imgs/2010/04/twers.jpg" alt="twers" width="115" height="123" /></a>it has four thoughtworkers; <a href="http://twitter.com/markryall">mark</a>, <a href="http://twitter.com/grillp">gill</a>, <a href="http://twitter.com/debbiecheong">debs</a> and <a href="http://twitter.com/evanbottcher">evan</a> and one sensiser; <a href="http://twitter.com/kornys">korny</a>. did korny perhaps work for thoughtworks in a previous life ;)</p>
<p>another interesting note is there exists a path from me to <a href="http://twitter.com/norvig">peter norvig</a> (who is too busy for twitter it seems) but only because of the huge connector nodes that exist in twitter. an example in this case is <a href="http://twitter.com/tuaw">TUAW</a> who follow 30,000+ people and have even more followers. these nodes cause a bit of noise in the system since they are slightly false representations of what a 'friend' means in my mind. not sure how to take these numbers into account...</p>
<p>things to do...</p>
<ul>
<li>the biggest oversimplification in this system is how i break ties for deciding which edge to cut out next if multiple exist with the same betweenness. currently it chooses the one that would make the most even sized break (based on smallest standard deviation of the connected components). though this is good for breaking a group into even sizes it's bad since it favours breaking a single element off a large group. this is what has caused the 'laddering' we see in the melbourne group.</li>
<li>the shortest path algorithm used to calculate edge betweenness is stochastic and if multiple shortest paths exist only one of them is chosen. it'd be better if all were considered with a weighting scheme.</li>
<li>it might be better to consider vertex betweenness instead of edge betweenness since one person could exist in multiple groups. if i started down this path though i think i'd rather just rewrite the lot using something like  the <a href="http://en.wikipedia.org/wiki/Clique_percolation_method">clique percolation method</a></li>
</ul>
<p><a href="http://github.com/matpalm/tgraph">all the code is on github</a></p>]]></content:encoded>
    </item>
    <item>
      <title>e10.5 revisiting community detection</title>
      <link>http://matpalm.com/blog/2010/03/30/e10-5-revisiting-community-detection/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[betweenness]]></category>
      <category><![CDATA[social network]]></category>
      <category><![CDATA[graph]]></category>
      <guid>http://matpalm.com/blog/?p=357</guid>
      <description>e10.5 revisiting community detection</description>
      <content:encoded><![CDATA[<p>i've decided to switch back to <a href="http://matpalm.com/blog/2009/10/06/e10-4-communities-in-social-graphs/">some previous work</a> i did on community detection in (social) graphs</p>
<p>the <a href="http://github.com/matpalm/tgraph/tree/master/girvan_newman">last chunk of code</a> i wrote which tried to deal with weighted directed graphs was terribly, terribly, broken but it seems that simplifying to undirected graphs is giving me much saner results. yay!</p>
<p>here's an example of my work in progress generated from <a href="http://github.com/matpalm/tgraph/tree/master/girvan_newman_2">the new version of the code</a></p>
<p>consider the graph</p>
<img class="aligncenter size-medium wp-image-358" title="p97" src="/blog/imgs/2010/03/p97-214x300.png" alt="p97" width="214" height="300" />

<p>and it's corresponding decomposition</p>
<img class="aligncenter size-full wp-image-360" title="p97.dendrogram" src="/blog/imgs/2010/03/p97.dendrogram.jpg" alt="p97.dendrogram" width="400" height="400" />

<p>the results are reasonable; the initial breaking of clusters [1,2,3,4,5,6] and [7,8,9,10,11,12] is the most obvious but some of the others are not as intuitive</p>
<p>[1,2,5] and [7,8,10] remain as unbreakable <a href="http://en.wikipedia.org/wiki/Clique_(graph_theory)">cliques</a> though it's arbitrary that 11 was broken off from [7,8,10] instead of 10 (arbitrary but an artifact related to my shortest path calculation for the edge betweenness)</p>
<p>the idea of identifying the edge to remove using <a href="http://en.wikipedia.org/wiki/Betweenness#Betweenness_centrality">edge betweenness</a> works well but it is often the case there are many edges with the same maximal betweeness and you have to choose only one. i think my current implementation of picking one is a bit naive and i'm not sure if i should move to a stochastic / <a href="http://en.wikipedia.org/wiki/Monte_Carlo_method">monte carlo style approach</a> or focus more on <a href="http://en.wikipedia.org/wiki/Community_structure#Modularity_maximization">modularity maximisation</a></p>]]></content:encoded>
    </item>
    <item>
      <title>e10.4 communities in social graphs</title>
      <link>http://matpalm.com/blog/2009/10/06/e10-4-communities-in-social-graphs/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[twitter]]></category>
      <category><![CDATA[social network]]></category>
      <category><![CDATA[betweenness]]></category>
      <category><![CDATA[algorithms]]></category>
      <category><![CDATA[graph]]></category>
      <guid>http://matpalm.com/blog/?p=83</guid>
      <description>e10.4 communities in social graphs</description>
      <content:encoded><![CDATA[<p>social graphs, like twitter or facebook, often follow the pattern of having clusters of highly connected components with an occasional edge joining these clusters.</p>
<p>these connecting edges define the boundaries of communities in the social network and can be identified by algorithms that measure <a href="http://en.wikipedia.org/wiki/Betweenness#Betweenness_centrality">betweenness</a>.</p>
<p>the <a href="http://en.wikipedia.org/wiki/Girvan-Newman_algorithm">girvan-newman algorithm</a> can be used to decompose a graph hierarchically based on successive removal of the edges with the highest betweenness.</p>
<p>the algorithm is basically</p>
<ol>
<li>calculate the betweenness of each edge (using an all shortest paths algorithm)</li>
<li>remove the edge(s) with the highest betweenness</li>
<li>check for connected components (using <a href="http://en.wikipedia.org/wiki/Tarjan%27s_strongly_connected_components_algorithm">tarjan's</a> algorithm)</li>
<li>repeat for graph or subgraphs if graph was split</li>
</ol>]]></content:encoded>
    </item>
    <item>
      <title>e10.3 twitter crawl progress</title>
      <link>http://matpalm.com/blog/2009/09/29/e10-3-twitter-crawl-progress/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[twitter]]></category>
      <category><![CDATA[algorithms]]></category>
      <category><![CDATA[hadoop]]></category>
      <guid>http://matpalm.com/blog/?p=70</guid>
      <description>e10.3 twitter crawl progress</description>
      <content:encoded><![CDATA[<p>since the twitter api is rate limited it's quite slow to crawl twitter and after a most of a week i've still only managed to get info on 8,000 users. i probably should subscribe to get a 20,000 an hr limit instead of the 150 i'm on now. i'll just let it chug along in the background of my pvr.</p>
<p>while the crawl has been going on i've been trying some things on the data to decide what to do with it.</p>
<p>i've managed to write a version of pagerank using <a href="http://hadoop.apache.org/pig/">pig</a> which has been very interesting. (for those who haven't seen it before pig is a query language that sits on top of hadoop's mapreduce). my initial feel for pig is that it's pretty awesome. it was <em>much</em> quicker to write this script than to write the <a href="http://matpalm.com/sip/">statistically improbable phrases</a>. in fact i'm reinspired to have another crack at the sip stuff using pig. my final result wasn't great for the performance of hadoop and after some <a href="http://mail-archives.apache.org/mod_mbox/hadoop-general/200909.mbox/%3C93d501de0909141814vaa8c9c0wc5a47ee05baae7de@mail.gmail.com%3E">great feedback on the hadoop mailing list</a> i've got a number of other things to try including writing my joins in pig.</p>
<p>anyways, here's my pagerank in pig</p>
<!--more-->

<p>done once</p>
<table class="pygments_murphytable"><tr><td class="linenos"><div class="linenodiv"><pre>1
2
3
4
5
6</pre></div></td><td class="code"><div class="pygments_murphy"><pre>edges = load &#39;edges&#39; as (from:chararray, to:chararray);
nodes = group edges by from;
node_contribs = foreach nodes generate group, 1.0 / (double)SIZE(edges) as contrib;
store node_contribs into &#39;node_contribs&#39;;
zero_contribs = foreach nodes generate group, (double)0 as contrib;
store zero_contribs into &#39;zero_contribs&#39;;
</pre></div>
</td></tr></table>

<p>done until convergence</p>
<table class="pygments_murphytable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16</pre></div></td><td class="code"><div class="pygments_murphy"><pre>page_rank = load &#39;$input&#39; as (node:chararray, rank:float);
node_contribs = load &#39;node_contribs&#39; as (node:chararray, contrib:double);
nodes_page_rank = join node_contribs by node, page_rank by node;
contribs = foreach nodes_page_rank {
  generate node_contribs::node, (double)node_contribs::contrib*(double)page_rank::rank as contrib;
}
edges = load &#39;edges&#39; as (from:chararray, to:chararray);
joined_divy_groups = join edges by from, contribs by node_contribs::node;
page_rank_contributions = foreach joined_divy_groups generate edges::to, contribs::contrib;
zero_contribs = load &#39;zero_contribs&#39; as (node:chararray, contrib:double);
page_rank_contributions_with_zero = union page_rank_contributions, zero_contribs;
group_page_ranks = group page_rank_contributions_with_zero by edges::to;
next_page_rank = foreach group_page_ranks {
  generate group, 0.15+(0.85*SUM(page_rank_contributions_with_zero.contribs::contrib));
}
store next_page_rank into &#39;$output&#39;;
</pre></div>
</td></tr></table>

<p>as for all my projects code is on <a href="http://github.com/matpalm/tgraph">github</a></p>]]></content:encoded>
    </item>
    <item>
      <title>e10.2 tgraph crawl order example</title>
      <link>http://matpalm.com/blog/2009/09/21/e10-2-tgraph-crawl-order-example/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[graph]]></category>
      <guid>http://matpalm.com/blog/?p=65</guid>
      <description>e10.2 tgraph crawl order example</description>
      <content:encoded><![CDATA[<p>let's consider an example of the crawl order for tgraph...</p>
<p>we seed our frontier with 'a' and bootstrap cost of 0.</p>
<p>fetching the info for 'a' shows 2 outedges to 'b' and 'c', from our cost formula these all have cost 0 + 1 + Log10(2+1) = 1.6</p>
<p>our frontier becomes [ {b,1.6}, {c,1.6} ]</p>
<p>next is 'b' and see it has an outdegree of 3, these nodes, b1 -&gt; b3, all have a cost of 1.6 + 1 + Log10(3+1) = 3.2</p>
<p>our frontier becomes [ {c,1.6}, {b1,3.2}, {b2,3.2}, {b3,3.2} ]</p>
<p>next is 'c' with an outdegree of 15. these 15 nodes, c1 -&gt; c15, have cost 1.6 + 1 + Log10(16) = 3.8</p>
<p>our frontier is now [ {b1,3.2}, {b2,3.2}, {b3,3.2}, {c1,3.8} ... {c15,3.8} ]</p>
<p>we would then continue with the 'b' nodes before the 'c' ones</p>
<p>note that this cost system is more than just an ordering, it allows an element at depth n+1 to be checked an element at depth n, if the cost of the latter is high enough.</p>]]></content:encoded>
    </item>
    <item>
      <title>e10.1 crawling twitter</title>
      <link>http://matpalm.com/blog/2009/09/19/e10-1-crawling-twitter/</link>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[twitter]]></category>
      <category><![CDATA[algorithms]]></category>
      <category><![CDATA[graph]]></category>
      <guid>http://matpalm.com/blog/?p=55</guid>
      <description>e10.1 crawling twitter</description>
      <content:encoded><![CDATA[<p>our first goal is to get some data and <a href="http://apiwiki.twitter.com/">the twitter api</a> makes getting the data trivial. i'm focused mainly on the <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-friends%C2%A0ids">friends</a> stuff but because it only gives user ids i'll also get the <a href="http://apiwiki.twitter.com/Twitter-REST-API-Method%3A-users%C2%A0show">user info</a> so i can put names to ids.</p>
<p>a <a href="http://en.wikipedia.org/wiki/Depth-first_search">depth first crawl</a> makes no sense for this one experiment, we're unlikely to get the entire graph and are more interested in following edges "close" to me. instead we'll use a <a href="http://en.wikipedia.org/wiki/Breadth-first_search">breadth first search</a>.</p>
<p>since any call to twitter is expensive (in time that is, they rate limit their api calls) instead of a plain vanilla breadth first we'll introduce a cost component to elements on the frontier so help decide what to grab next. this is especially important for a graph like  twitter where the outdegree of a node is often in the hundreds. it turns the crawl into something that is not strictly depth first but it works out.</p>
<p>to explain the cost component consider the expected connectivity of nodes in the twitter friend graph. most nodes have an outdegree of the order 20-200. occasionally you see much larger (in the 1000's) or much smaller (under 10).</p>
<p>we might, naively perhaps, say that having a large outdegree means the person is a bit less strict with her following criteria and that some of them are not really that important to her. if this is the case we should focus a little more  on getting nodes with smaller outdegree.</p>
<p>the formula i've come up with is to not consider the depth but instead add 1 + Log10(1+the outdegree of the previous node). in this way we penalise large outdegress, but not by a huge amount. we always add 1 to counter the cases where there are no edges leaving a node.</p>]]></content:encoded>
    </item>
    <item>
      <title>e10.0 introducing tgraph</title>
      <link>http://matpalm.com/blog/2009/09/19/e10-0-introducing-tgraph/</link>
      <category><![CDATA[big data]]></category>
      <category><![CDATA[e10]]></category>
      <category><![CDATA[twitter]]></category>
      <category><![CDATA[hadoop]]></category>
      <category><![CDATA[pig]]></category>
      <category><![CDATA[algorithms]]></category>
      <guid>http://matpalm.com/blog/?p=47</guid>
      <description>e10.0 introducing tgraph</description>
      <content:encoded><![CDATA[<p>so <a href="http://matpalm.com/sip/">e9 sip</a> is on hold for a bit while i kick off e10 tgraph. was looking for another problem to try hadoop with and came across a classic graph one, <a title="pagerank" href="http://en.wikipedia.org/wiki/PageRank">pagerank</a>. a well understood algorithm like page rank will be a  great chance to try <a href="http://hadoop.apache.org/pig/">pig</a>, the query language that sits on top of hadoop mapreduce.</p>
<p>so we need a graph to work on. my first thoughts were using one of the <a href="http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2596">wikipedia linkage dumps</a> but it feels a bit sterile. instead it's a good excuse to do a little crawl of the following graph of twitter.</p>
<p>this will also be a chance to try to document a project via a blog. <a href="http://www.skorks.com/">skorks</a>' incessant blog rambling has convinced me to give it a go.</p>]]></content:encoded>
    </item>
  </channel>
</rss>

