Skip to content

Commit 130ce06

Browse files
authored
Update kMeans.py
1 parent 6d1a38f commit 130ce06

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Clustering/kMeans - Standard/kMeans.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def CalculateMeans(k,items,maxIterations=100000):
111111

112112
#Initialize clusters, the array to hold
113113
#the number of items in a class
114-
clusterLengths = [0 for i in range(len(means))];
114+
clusterSizes = [0 for i in range(len(means))];
115115

116116
#An array to hold the cluster an item is in
117117
belongsTo = [0 for i in range(len(items))];
@@ -127,8 +127,8 @@ def CalculateMeans(k,items,maxIterations=100000):
127127

128128
index = Classify(means,item);
129129

130-
clusterLengths[index] += 1;
131-
means[index] = UpdateMean(clusterLengths[index],means[index],item);
130+
clusterSizes[index] += 1;
131+
means[index] = UpdateMean(clusterSizes[index],means[index],item);
132132

133133
#Item changed cluster
134134
if(index != belongsTo[i]):

0 commit comments

Comments
 (0)