def main(): # load sample data X = multivariate_normal.load_data() # do repeated bisection clustering n_clusters = 2 clusters, cluster_centers = repeated_bisection(X, n_clusters) # show results show_results(clusters, cluster_centers, n_clusters)
def main(): # sample data X = multivariate_normal.load_data() # kmeans clustering k = 2 Xnew, new_labels = kmeans(X, k) # plot colors = ['r', 'b'] for i in range(k): plt.scatter(Xnew[new_labels == i, 0], Xnew[new_labels == i, 1], color=colors[i], marker='x') plt.show()
def main(): # sample data X = multivariate_normal.load_data() # kmeans++ k = 2 Xnew, new_labels = kmeanspp(X, k) # plot colors = ['r', 'b'] for i in range(k): plt.scatter(Xnew[new_labels == i, 0], Xnew[new_labels == i, 1], color=colors[i], marker='x') plt.show()
def main(): # sample data X = multivariate_normal.load_data() # mean shift clustering bandwidth = estimate_bandwidth(X, n_samples=500) cluster_centers, points_labels = mean_shift_clustering(X, bandwidth) print '*** My mean-shift clustering' print_results(cluster_centers, points_labels) # mean shift clustering by sklearn ms = MeanShift(bandwidth=bandwidth, bin_seeding=True) ms.fit(X) print '*** Mean-shift clustering by sklearn' print_results(ms.cluster_centers_, ms.labels_) # plot results plot_results(X, cluster_centers, points_labels, ms)