本文整理汇总了Python中Vector.lower方法的典型用法代码示例。如果您正苦于以下问题:Python Vector.lower方法的具体用法?Python Vector.lower怎么用?Python Vector.lower使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.lower方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Cluster
# 需要导入模块: import Vector [as 别名]
# 或者: from Vector import lower [as 别名]
#.........这里部分代码省略.........
# calc centroid: SUM of all items in each cluster
for idx, info in enumerate(self.iteminfo):
c = self.cluster[info[1]]
c[0] += self.iteminfo[idx][0]
c[1] += 1
#print "Item[%d] --> Cluster[%d]" % (idx, info[1])
# calc centroid: AVG of all items in each cluster
for c in self.cluster:
if c[1] > 0:
#c[0] = c[0] / c[1]
c[0] /= c[1]
def calcRadius(self):
# init cluster info
for c in self.cluster:
c[2] = 0.0
for idx, info in enumerate(self.iteminfo):
c = self.cluster[info[1]]
diff = info[0] - c[0]
c[2] += diff.ksdsize()
for c in self.cluster:
if c[1] > 0:
c[2] = c[2] / c[1]
def getMinMaxItems(self):
self.itemMAX = Vector(self.iteminfo[0][0])
self.itemMIN = Vector(self.iteminfo[0][0])
self.itemMEAN = Vector(self.iteminfo[0][0])
for idx in range(1, len(self.iteminfo)):
self.itemMAX.upper( self.iteminfo[idx][0] )
self.itemMIN.lower( self.iteminfo[idx][0] )
self.itemMEAN += self.iteminfo[idx][0]
#print self.iteminfo[idx][0].str()
#print self.itemMAX.str()
#print self.itemMIN.str()
self.itemMEAN /= len(self.iteminfo)
def calcIntraClusterDistance(self, debug=0):
#if len(self.cluster) < 2:
# return
for i in range(self.k):
self.clusterDistanceMatrix.append([None] * self.k)
for i in range(self.k):
for j in range(i+1):
if i==j:
self.clusterDistanceMatrix[i][j] = 0.0
continue
D = self.cluster[i][0] - self.cluster[j][0]
self.clusterDistanceMatrix[i][j] = self.clusterDistanceMatrix[j][i] = D.ksdsize()
#print "%d %d : %.2f" % (i,j, D.ksdsize())
if debug: print "Intra: %d %d : %.2f" % (i,j, self.clusterDistanceMatrix[i][j])
def prnIntraCluster(self, fd=sys.stdout):
if self.clusterDistanceMatrix == None:
return
print "-"*10, "Intra-Cluster Distance"
for i in range(self.k):
for j in range(self.k):