title: sklearn cosine similarity :: AttributeError: 'module' object has no attribute 'metrics'
body: <pre><code>ur[5][8]=
  [[0,3,4,0,0,0,5,0],
  [4,5,0,0,0,0,3,0],
  [0,4,0,3,0,0,1,4],
  [2,0,5,0,0,0,3,0],
  [0,0,0,5,0,0,0,4]]
  </code></pre>
  
  <p>0 means movie not rated
  i want to predict the rating of the unrated movie of each user using cosine similarity and after calculating similarity I pick up k most similar user and predict according to that</p>
  
  <p>but how to calculate the cosine similarity using inbuilt function in skearn library or any other</p>
  
  <pre><code>code:
  similar=[[0] * 5 for i in range(5)]
  print similar
  for x in range(0,5):
      for y in range(0,5):
          similar[x][y] = sklearn.metrics.pairwise.cosine_similarity(ur[x],ur[y])
  
  error :
  runfile('C:/Users/Nitin/cf/first.py', wdir='C:/Users/Nitin/cf')
  [[0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]]
  Traceback (most recent call last):
  
    File "&lt;ipython-input-18-e55296403aad&gt;", line 1, in &lt;module&gt;
      runfile('C:/Users/Nitin/cf/first.py', wdir='C:/Users/Nitin/cf')
  
    File "C:\Users\Nitin\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 880, in runfile
      execfile(filename, namespace)
  
    File "C:\Users\Nitin\Anaconda2\lib\site-packages\spyder\utils\site\sitecustomize.py", line 87, in execfile
      exec(compile(scripttext, filename, 'exec'), glob, loc)
  
    File "C:/Users/Nitin/cf/first.py", line 23, in &lt;module&gt;
      similar[x][y] = sklearn.metrics.pairwise.cosine_similarity(ur[x],ur[y])
  
  AttributeError: 'module' object has no attribute 'metrics'
  </code></pre>
  
  <p>What to pass in cosine_similarity or how to do this correctly</p>