def cluster_data(data, cluster_cnt, iter=20, thresh=1e-05):
 wh_data = vq.whiten(data)
 (code_book, dist) = vq.kmeans(wh_data, cluster_cnt, iter, thresh)
 (code_ids, distortion) = vq.vq(wh_data, code_book)
 clusters = []
 for i in range(len(code_book)):
  cluster = np.compress((code_ids == i), data, 0)
  clusters.append(cluster)
 return clusters

def cluster_data ( data , cluster_cnt , iter = 20 , thresh = 1e-05 ) : wh_data = vq . whiten ( data ) ( code_book , dist ) = vq . kmeans ( wh_data , cluster_cnt , iter , thresh ) ( code_ids , distortion ) = vq . vq ( wh_data , code_book ) clusters = [ ] for i in range ( len ( code_book ) ) : cluster = np . compress ( ( code_ids == i ) , data , 0 ) clusters . append ( cluster ) return clusters
group data into a number of common clusters data -- 2d array of data points .