Skip to content

Commit 9145ff3

Browse files
committed
Remove unused KmeansClusterer and fix bad iterations assignment
1 parent ba0deb8 commit 9145ff3

File tree

1 file changed

+1
-49
lines changed

1 file changed

+1
-49
lines changed

spectral/algorithms/clustering.py

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -22,54 +22,6 @@ def L2(v1, v2):
2222
return np.sqrt(np.dot(delta, delta))
2323

2424

25-
class KmeansClusterer(Classifier):
26-
'''An unsupervised classifier using an iterative clustering algorithm'''
27-
def __init__(self, nclusters=10, maxIter=20, endCondition=None,
28-
distanceMeasure=L1):
29-
'''
30-
ARGUMENTS:
31-
nclusters Number of clusters to create. Default is 8
32-
maxIter Max number of iterations. Default is 20
33-
endCondition Optional comparison function. This should be a
34-
function which takes 2 MxN NumPy arrays as its
35-
arguments and returns non-zero when clustering
36-
is to be terminated. The two arguments are the
37-
cluster maps for the previous and current cluster
38-
cycle, respectively.
39-
distanceMeasure The distance measure to use for comparison. The
40-
default is the L1 distance. For Euclidean
41-
distance, specify L2 (no quotes).
42-
'''
43-
self.nclusters = nclusters
44-
self.maxIterations = maxIter
45-
self.endCondition = endCondition
46-
self.distanceMeasure = distanceMeasure
47-
48-
def classify_image(self, image, startClusters=None, iterations=None):
49-
'''
50-
Performs iterative self-organizing clustering of image data.
51-
52-
USAGE: (clMap, centers) = cl.classify_image(image
53-
[, startClusters = None]
54-
[, iterations = None])
55-
56-
ARGUMENTS:
57-
image A SpyFile or an MxNxB NumPy array
58-
startClusters Initial cluster centers. This must be an
59-
nclusters x B array.
60-
iterations If this argument is passed and is a list object,
61-
each intermediate cluster map is appended to
62-
the list.
63-
RETURN VALUES:
64-
clMap An MxN array whos values are the indices of the
65-
cluster for the corresponding element of image.
66-
centers An nclusters x B array of cluster centers.
67-
'''
68-
return isoCluster(
69-
image, self.nclusters, self.maxIterations, startClusters,
70-
self.endCondition, self.distanceMeasure, iterations)
71-
72-
7325
def kmeans(image, nclusters=10, max_iterations=20, **kwargs):
7426
'''
7527
Performs iterative clustering using the k-means algorithm.
@@ -162,7 +114,7 @@ def kmeans(image, nclusters=10, max_iterations=20, **kwargs):
162114
if not hasattr(val, 'append'):
163115
raise TypeError('"frames" keyword argument must have "append"'
164116
'attribute.')
165-
iterations = frames
117+
iterations = val
166118
else:
167119
raise NameError('Unsupported keyword argument.')
168120

0 commit comments

Comments
 (0)