from numpy import array
from scipy.cluster.vq import vq, kmeans, whiten
from dml.CLUSTER.spectralCluster import SCC
import matplotlib.pyplot as plt
'''
features  = array([
[1,6,11.05],
[1,7.35,10.6],
[1,8.35,8.35],
[1,10.1,7.8],
[1,10.2,8.7],
[1,9.25,10],
[1,8.05,10.8],
[1,6.6,11.6],
[1,6.4,9.15],
[1,8.35,8.25],
[1,9.5,7.05],
[1,9.05,8.85],
[1,8.2,9.45],
[1,7.15,9.4],
[1,7.3,7.75],
[1,8.2,6.7],
[1,15.45,17.3],
[1,16.35,16.35],
[1,17.45,16.5],
[1,18.05,17.45],
[1,17.5,18.6],
[1,16.1,18.9],
[1,16.75,17.5],
[1,17.55,17.45],
[1,15.95,18.35],
[1,15.2,18],
[1,15,17.45],
[1,19.75,8.25],
[1,20.75,7.9],
[1,25.65,8.2],
[1,25.05,10.5],
[1,22.85,11.2],
[1,21.6,9.9],
[1,23.05,8.3],
[1,24.65,8.8],
[1,23.55,10.1],
[1,23.05,9.45],
[1,23.2,8.35],
[1,24.2,7.95],
[1,22.15,7.1],
[1,21.6,7.8],
[1,21.7,8.2]])
'''
features=array([
[13.45,11.95],
[14.15,11.75],
[14.8,11.25],
[15.35,10.35],
[15,9.55],
[14.05,9.3],
[13.05,10.2],
[13.5,11.3],
[14.4,10.95],
[14.85,10.05],
[13.75,9.65],
[13.85,10.65],
[14.15,10.6],
[14.3,9.95],
[13.85,9.5],
[13.3,10.6],
[13.25,11.45],
[12.8,11],
[13.95,9.2],
[14.85,9.65],
[10.4,13.95],
[10.05,13.9],
[9.55,12.75],
[9.3,11.75],
[9.3,10.5],
[9.7,9.1],
[10.4,8.25],
[11.65,7.05],
[12.9,6.45],
[13.85,6.35],
[15.3,6.65],
[16.7,7.4],
[17.5,8.25],
[18.25,9.05],
[18.75,10.2],
[18.65,11.35],
[18.25,12.5],
[17.4,13.75],
[16.6,14.75],
[15.05,15.35],
[12.7,15.25],
[10.55,14.55],
[9.95,13.95],
[9.3,12.65],
[9.1,11],
[9.2,10],
[10.2,8.65],
[10.85,7.7],
[12,7],
[13.2,6.55],
[14.45,6.6],
[15.4,6.8],
[16.9,7.15],
[17.35,7.55],
[18.05,8.45],
[18.35,9.2],
[18.75,9.8],
[18.9,10.35],
[18.9,11.05],
[18.8,12.15],
[18.3,12.65],
[17.8,13.4],
[16.95,14.15],
[16.1,14.8],
[14.8,15.35],
[13.55,15.35],
[11.6,15],
[10.4,14.25],
[11.3,14.4],
[12.2,15.15],
[12.45,15.35],
[13.05,15.4],
[13.85,15.25]]
)
a=SCC(features,2)
a.train(maxiter=180)
print a.labels

for i in range(features.shape[0]):
	if  a.labels[i]==0:
		plt.plot(features[i][0],features[i][1],'or')
	else:
		plt.plot(features[i][0],features[i][1],'ob')
plt.show()
#print a.result()
#print a.bfWhiteCen()
from numpy import array
from scipy.cluster.vq import vq, kmeans, whiten
from dml.CLUSTER.spectralCluster import SCC
import matplotlib.pyplot as plt
'''
features  = array([
[1,6,11.05],
[1,7.35,10.6],
[1,8.35,8.35],
[1,10.1,7.8],
[1,10.2,8.7],
[1,9.25,10],
[1,8.05,10.8],
[1,6.6,11.6],
[1,6.4,9.15],
[1,8.35,8.25],
[1,9.5,7.05],
[1,9.05,8.85],
[1,8.2,9.45],
[1,7.15,9.4],
[1,7.3,7.75],
[1,8.2,6.7],
[1,15.45,17.3],
[1,16.35,16.35],
[1,17.45,16.5],
[1,18.05,17.45],
[1,17.5,18.6],
[1,16.1,18.9],
[1,16.75,17.5],
[1,17.55,17.45],
[1,15.95,18.35],
[1,15.2,18],
[1,15,17.45],
[1,19.75,8.25],
[1,20.75,7.9],
[1,25.65,8.2],
[1,25.05,10.5],
[1,22.85,11.2],
[1,21.6,9.9],
[1,23.05,8.3],
[1,24.65,8.8],
[1,23.55,10.1],
[1,23.05,9.45],
[1,23.2,8.35],
[1,24.2,7.95],
[1,22.15,7.1],
[1,21.6,7.8],
[1,21.7,8.2]])
'''
features=array([
[13.45,11.95],
[14.15,11.75],
[14.8,11.25],
[15.35,10.35],
[15,9.55],
[14.05,9.3],
[13.05,10.2],
[13.5,11.3],
[14.4,10.95],
[14.85,10.05],
[13.75,9.65],
[13.85,10.65],
[14.15,10.6],
[14.3,9.95],
[13.85,9.5],
[13.3,10.6],
[13.25,11.45],
[12.8,11],
[13.95,9.2],
[14.85,9.65],
[10.4,13.95],
[10.05,13.9],
[9.55,12.75],
[9.3,11.75],
[9.3,10.5],
[9.7,9.1],
[10.4,8.25],
[11.65,7.05],
[12.9,6.45],
[13.85,6.35],
[15.3,6.65],
[16.7,7.4],
[17.5,8.25],
[18.25,9.05],
[18.75,10.2],
[18.65,11.35],
[18.25,12.5],
[17.4,13.75],
[16.6,14.75],
[15.05,15.35],
[12.7,15.25],
[10.55,14.55],
[9.95,13.95],
[9.3,12.65],
[9.1,11],
[9.2,10],
[10.2,8.65],
[10.85,7.7],
[12,7],
[13.2,6.55],
[14.45,6.6],
[15.4,6.8],
[16.9,7.15],
[17.35,7.55],
[18.05,8.45],
[18.35,9.2],
[18.75,9.8],
[18.9,10.35],
[18.9,11.05],
[18.8,12.15],
[18.3,12.65],
[17.8,13.4],
[16.95,14.15],
[16.1,14.8],
[14.8,15.35],
[13.55,15.35],
[11.6,15],
[10.4,14.25],
[11.3,14.4],
[12.2,15.15],
[12.45,15.35],
[13.05,15.4],
[13.85,15.25]]
)
a=SCC(features,2)
a.train(maxiter=180)
print a.labels

for i in range(features.shape[0]):
	if  a.labels[i]==0:
		plt.plot(features[i][0],features[i][1],'or')
	else:
		plt.plot(features[i][0],features[i][1],'ob')
plt.show()
#print a.result()
#print a.bfWhiteCen()
features  = array([ [1,6,11.05], [1,7.35,10.6], [1,8.35,8.35], [1,10.1,7.8], [1,10.2,8.7], [1,9.25,10], [1,8.05,10.8], [1,6.6,11.6], [1,6.4,9.15], [1,8.35,8.25], [1,9.5,7.05], [1,9.05,8.85], [1,8.2,9.45], [1,7.15,9.4], [1,7.3,7.75], [1,8.2,6.7], [1,15.45,17.3], [1,16.35,16.35], [1,17.45,16.5], [1,18.05,17.45], [1,17.5,18.6], [1,16.1,18.9], [1,16.75,17.5], [1,17.55,17.45], [1,15.95,18.35], [1,15.2,18], [1,15,17.45], [1,19.75,8.25], [1,20.75,7.9], [1,25.65,8.2], [1,25.05,10.5], [1,22.85,11.2], [1,21.6,9.9], [1,23.05,8.3], [1,24.65,8.8], [1,23.55,10.1], [1,23.05,9.45], [1,23.2,8.35], [1,24.2,7.95], [1,22.15,7.1], [1,21.6,7.8], [1,21.7,8.2]]) #print a.result() #print a.bfWhiteCen()