Пример #1
0
 def infer_one(self, user_id):
     points = []
     user_venues = self.venues.get_venues(user_id)
     for venue_name in user_venues:
         p = self.venues.get_point(venue_name)
         points.append(p)
     if len(points) > 0:
         centroid = Util.calc_medoid(points)
         return centroid
     else:
         return None
Пример #2
0
 def infer_one(self, user_id):
     points = []
     for fid in self.graph.get_followers(user_id):
         user = self.users.get(fid)
         if user != None:
             if user['location_point'] != None:
                 points.append(user['location_point'])
     if len(points) > 0:
         #centroid = Util.calc_centroid(points)
         centroid = Util.calc_medoid(points)
         return centroid
     else:
         return None
Пример #3
0
 def select(self, user):
     friends = set(self.graph.get_friends(user['id']))
     followers = set(self.graph.get_followers(user['id']))
     neighbors = friends | followers
     locations = []
     for neighbor_id in neighbors:
         if self.mapping[neighbor_id] != None:
             locations.append(self.mapping[neighbor_id])
     if len(locations) > 0:
         geometric_median = Util.calc_medoid(locations)
         return geometric_median
     else:
         return None