title: Recommendation Engine: Cosine Similarity vs Measuring %difference between each vector component
body: <p>Lets say I have a database of users who rate different products on a scale of 1-5. Our recommendation engine recommends products to users based on the preferences of other users who are highly similar. My first approach to finding similar users was to use Cosine Similarity, and just treat user ratings as vector components. The main problem with this approach is that it just measures vector angles and doesn't take rating scale or magnitude into consideration.</p>
  
  <p><strong>My question is this:</strong>
  <em>Can somebody explain to me why Cosine Similarity is in any way better suited for judging user similarity than <strong>simply measuring the percent difference between the vector components of two vectors</strong>(users)?</em> </p>
  
  <p><strong>For Example, why not just do this:</strong></p>
  
  <pre><code>n = 5 stars
  a = (1,4,4)
  b = (2,3,4)
  
  similarity(a,b) = 1 - ( (|1-2|/5) + (|4-3|/5) + (|4-4|/5) ) / 3 = .86667
  </code></pre>
  
  <p><strong>Instead of Cosine Similarity :</strong></p>
  
  <pre><code>a = (1,4,4)
  b = (2,3,4)
  
  CosSimilarity(a,b) = 
  (1*2)+(4*3)+(4*4) / sqrt( (1^2)+(4^2)+(4^2) ) * sqrt( (2^2)+(3^2)+(4^2) ) = .9697
  </code></pre>