def test_nearest_cosine_similarity(self):
     users = {
         "John": {
             "a": 1,
             "b": 2,
             "c": 3
         },
         "Sarah": {
             "a": 1,
             "b": 2,
             "c": 3
         },
         "Andrew": {
             "a": -1,
             "b": -2,
             "c": -3
         }
     }
     nearest = similarity.nearest_cosine("John", users)
     self.assertEqual(nearest, [(0.0, 'Sarah'), (2.0, 'Andrew')])
 def test_nearest_cosine_similarity(self):
     users = {
         "John": {
             "a": 1,
             "b": 2,
             "c": 3
         },
         "Sarah": {
             "a": 1,
             "b": 2,
             "c": 3
         },
         "Andrew": {
             "a": -1,
             "b": -2,
             "c": -3
         }
     }
     nearest = similarity.nearest_cosine("John", users)
     self.assertEqual(nearest, [(0.0, 'Sarah'), (2.0, 'Andrew')])
Beispiel #3
0
 def recommend(self, k):
   return similarity.nearest_cosine(k, self.data)[0]
Beispiel #4
0
 def recommend(self, k):
     return similarity.nearest_cosine(k, self.data)[0]