title: How does statistical calculation of "similar products/music/..." from customer buying/listening behaviour work?
body: <p>I mean product suggestions on Amazon or more specifically similar band recommendation on Last.fm. </p>
  
  <p>Given that you can store the complete listening/buying behaviour of your users (WHO listened to WHAT how OFTEN?), how do you calculate which bands are similar to any given bands, and how much?</p>
  
  <p>I've found some sites on Wikipedia (<a href="http://en.wikipedia.org/wiki/Association_rule_learning" rel="nofollow">Association rule learning</a>, <a href="http://en.wikipedia.org/wiki/Affinity_analysis" rel="nofollow">Affinity analysis</a>) but I'd like to get some information from a programmer's point of view and preferably some pseudocode or Python code for it.</p>
  
  <p>Given that I have</p>
  
  <pre><code> dic = {
  "Alice"   : { "AC/DC" : 2, "The Raconteurs" : 3, "Mogwai" : 1 },
  "Bob"     : { "The XX" : 4, "Lady Gaga" : 3, "Mogwai" : 1, "The Raconteurs" : 1 }
  "Charlie" : { "AC/DC" : 7, "Lady Gaga" : 7 }
   }
  </code></pre>
  
  <p>where the numbers are play counts, how would I iterate over this to find the similarity of the bands?</p>