pycl/Code/KMeans.py
def findMostDistant(vectorspace, k):
	"""Find the most distant k vectors."""
	distances = [ ]
	for x in range(len(vectorspace)):
		dv = [ ]
		for y in range(x + 1, len(vectorspace)):
			dv.append(EuclideanDistance(vectorspace[x], vectorspace[y]))
		distances.append(dv)

	dv = [ ]
	for x in distances:
		dv += x
	dv.sort()

	vectors = [ ]
	for x in range(len(distances)):
		for y in range(len(distances[x])):
			if distances[x][y] in dv[-k:]:
				if x not in vectors:
					vectors.append(x)
				if y not in vectors:
					vectors.append(y)
	return vectors[:k]
Find the most distant k vectors.
Find the most distant k vectors.
Find the most distant k vectors .
def findMostDistant(vectorspace, k):
	distances = [ ]
	for x in range(len(vectorspace)):
		dv = [ ]
		for y in range(x + 1, len(vectorspace)):
			dv.append(EuclideanDistance(vectorspace[x], vectorspace[y]))
		distances.append(dv)
	dv = [ ]
	for x in distances:
		dv += x
	dv.sort()
	vectors = [ ]
	for x in range(len(distances)):
		for y in range(len(distances[x])):
			if distances[x][y] in dv[-k:]:
				if x not in vectors:
					vectors.append(x)
				if y not in vectors:
					vectors.append(y)
	return vectors[:k]
def findMostDistant ( vectorspace , k ) : distances = [ ] for x in range ( len ( vectorspace ) ) : dv = [ ] for y in range ( x + 1 , len ( vectorspace ) ) : dv . append ( EuclideanDistance ( vectorspace [ x ] , vectorspace [ y ] ) ) distances . append ( dv ) dv = [ ] for x in distances : dv += x dv . sort ( ) vectors = [ ] for x in range ( len ( distances ) ) : for y in range ( len ( distances [ x ] ) ) : if distances [ x ] [ y ] in dv [ - k : ] : if x not in vectors : vectors . append ( x ) if y not in vectors : vectors . append ( y ) return vectors [ : k ]
Find the most distant k vectors.
Find the most distant k vectors .
"""Find the most distant k vectors."""
vectorspace
k