本文整理汇总了Python中lib.util.Util.calc_medoid方法的典型用法代码示例。如果您正苦于以下问题:Python Util.calc_medoid方法的具体用法?Python Util.calc_medoid怎么用?Python Util.calc_medoid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib.util.Util
的用法示例。
在下文中一共展示了Util.calc_medoid方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: infer_one
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import calc_medoid [as 别名]
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: infer_one
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import calc_medoid [as 别名]
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: select
# 需要导入模块: from lib.util import Util [as 别名]
# 或者: from lib.util.Util import calc_medoid [as 别名]
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