Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Produced k vs gmeans metric avg over all clusters

  • Loading branch information...
commit 7f32489f9d297faa2319ab1d8192fb28c4b3ba72 1 parent d2c70f9
@dcsommer authored
View
16 gmeans_cluster.m
@@ -1,13 +1,15 @@
-function [CenterIds, Centers] = gmeans_cluster(features, crit, maxClusters)
+function [CenterIds, Centers, ks, means] = gmeans_cluster(features, crit, maxClusters)
oldk = 1;
k = 16;
fprintf('Initial cluster with %d centers\n', k);
[CenterIds, Centers] = kmeans(features, k);
+a=1;
while oldk ~= k && k < maxClusters
oldk = k;
+ A2SZ = zeros(size(Centers,1), 1);
for i=1:size(Centers,1)
- fprintf('checking center %d of %d\n', i, size(Centers,1))
+ %fprintf('checking center %d of %d\n', i, size(Centers,1))
is = features(CenterIds == i,:);
if (size(is, 1) < 2)
continue;
@@ -26,12 +28,14 @@
sum = sum + (2*j - 1)*(log(Z(j)) + log(1 - Z(n+1-j)));
end
A2Z = -n - sum/n;
- A2SZ = A2Z*(1 + 4/n - 25/n^2)
- n
- if A2SZ > crit
+ A2SZ(i) = A2Z*(1 + 4/n - 25/n^2);
+ if A2SZ(i) > crit
k = k+1; % reject null hypothesis, there should be 2 clusters
end
end
- fprintf('reclustering with %d centers\n', k)
+ ks(a) = k;
+ means(a) = mean(A2SZ);
+ fprintf( 'reclustering with %d centers\n', k)
[CenterIds, Centers] = kmeans(features, k);
+ a = a+1;
end
View
BIN  poster/images/gmeans_k_vs_metric.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
3  runall.m
@@ -25,5 +25,4 @@
%reduced_features = polyfit(features, REDUCED_DIMENSION,30);
disp '-----Clustering-----'
-[CenterIds, Centers] = gmeans_cluster(reduced_features, GMEANS_CRIT, MAX_CLUSTERS);
-
+[CenterIds, Centers] = gmeans_cluster(reduced_features, GMEANS_CRIT, MAX_CLUSTERS);
Please sign in to comment.
Something went wrong with that request. Please try again.