本文整理汇总了Python中cluster.Cluster.centroide方法的典型用法代码示例。如果您正苦于以下问题:Python Cluster.centroide方法的具体用法?Python Cluster.centroide怎么用?Python Cluster.centroide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cluster.Cluster
的用法示例。
在下文中一共展示了Cluster.centroide方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reduce_pareto_set
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import centroide [as 别名]
def reduce_pareto_set(self, par_set):
"""
Realiza el clustering
"""
lista_cluster=[]
for solucion in par_set.solutions:
cluster = Cluster()
cluster.agregar_solucion(solucion)
lista_cluster.append(cluster)
while len(lista_cluster) > self.max_pareto_points:
min_distancia = sys.maxint
for i in range (0,len(lista_cluster)-1):
for j in range(i+1, len(lista_cluster)-1):
c = lista_cluster[i]
distancia = c.calcular_distancia(lista_cluster[j])
if distancia < min_distancia:
min_distancia = distancia
c1 = i
c2 = j
cluster = lista_cluster[c1].unir(lista_cluster[c2]) #retorna un nuevo cluster
del lista_cluster[c1]
del lista_cluster[c2]
lista_cluster.append(cluster)
par_set=[]
for cluster in lista_cluster:
solucion = cluster.centroide()
par_set.append(solucion)
return par_set
示例2: get_cluster_obs
# 需要导入模块: from cluster import Cluster [as 别名]
# 或者: from cluster.Cluster import centroide [as 别名]
def get_cluster_obs(clusters, r):
res = Cluster(-1, [])
for c in clusters:
for obs_row in c.observations:
if obs_row == r:
res.id = c.id
res.centroide = c.centroide
res.observations = c.observations
return res