for j in range(0, len(cluster)):
		if phi[j]==0:
			cluster1.append(cluster[j])
			indexes1.append(j+1)
		elif phi[j]==1:
			cluster2.append(cluster[j])
			indexes2.append(j+1)
		elif phi[j]==2:
			cluster3.append(cluster[j])
			indexes3.append(j+1)

print '\n Indexes are :'
print '******************************'
print 'Cluster 1:', indexes1
print '******************************'
print 'Cluster 2:', indexes2
print '******************************'
print 'Cluster 3:', indexes3
print '******************************'


	
""" Plotting the data """

title="Clustering using Llyods algorithm with C initially with points indexed {1,2,3}"
HC.lloyds_plot(cluster,phi,c,title)	
	
	
Exemple #2
0
    x = phi[i]
    means_cost += (((c[x][0] - cluster[i][0])**2 +
                    (c[x][1] - cluster[i][1])**2)**0.5)**2

#means_cost=means_cost/ float(len(cluster))

print '3-means cost is :', means_cost

print '\n Indexes are :'
print '******************************'
print 'Cluster 1:', indexes1
print '******************************'
print 'Cluster 2:', indexes2
print '******************************'
print 'Cluster 3:', indexes3
print '******************************'
""" Plotting the data """

title = "Clustering using Gonzalez algorithm "
HC.lloyds_plot(cluster, phi, c, title)
"""
print '\n Subsets are :'
print '******************************'
print 'Subset 1:', subset1
print '******************************'
print 'Subset 2:', subset2
print '******************************'
print 'Subset 3:', subset3
print '******************************'
"""