本文整理汇总了Python中helper.Helper.verbose_print方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.verbose_print方法的具体用法?Python Helper.verbose_print怎么用?Python Helper.verbose_print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.Helper
的用法示例。
在下文中一共展示了Helper.verbose_print方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: kmeans_centroids
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import verbose_print [as 别名]
def kmeans_centroids(self, clusters):
'''Calculate centroids based on clusters by doing a mean between
all states within the same cluster.
'''
Helper.verbose_print('Centroids: ' + str(self.get_centroids_count(clusters)))
new_centroids = [0 for _ in range(self.k)]
for i in range(self.k):
state_sum = tuple([(0,0) for _ in range(self.coord_nr)])
nr = 0.0
for state,cluster in clusters.iteritems():
if cluster == i:
nr += 1
state_sum = self.add_states(state_sum, state)
# At least one representat for a cluster should exist.
if nr > 0:
# Now divide by the number of members in a cluster every coordinate.
new_centroids[i] = map(lambda coord: self.__divide_coord(coord, nr),
state_sum)
# Treat the case of finding no member in cluster by making it be
# infinity everywhere.
else:
new_centroids[i] = map(lambda coord: tuple([Preprocess.INFINITY
for c in coord]),
state_sum)
return new_centroids