Hi,
I am working with an implementation of the mean shift algorithm using sklearn.cluster from
http://scikit-learn.org/stable/auto_examples/cluster/plot_mean_shift.html
and would like to compute the ellipses around the clusters.
Is there an implementation for this?
Thanks
http://scikit-learn.org/stable/auto_examples/cluster/plot_mean_shift.html
and would like to compute the ellipses around the clusters.
Is there an implementation for this?
Thanks
""" ============================================= A demo of the mean-shift clustering algorithm =============================================
Reference: Dorin Comaniciu and Peter Meer, "Mean Shift: A robust approach toward feature space analysis". IEEE Transactions on Pattern Analysis and Machine Intelligence. 2002. pp. 603-619. """ print(__doc__) import numpy as np from sklearn.cluster import MeanShift, estimate_bandwidth from sklearn.datasets.samples_generator import make_blobs import numpy as np from read_data import read_data slide = 15 data = read_data() points = data[slide] X = np.array(points) ############################################################################### # Generate sample datacenters = [[1, 1], [-1, -1], [1, -1]] #, _ = make_blobs(n_samples=1000, centers=centers, cluster_std=0.6) ############################################################################### # Compute clustering with MeanShift # print bandwidth bandwidth = 100 ms = MeanShift(bandwidth=bandwidth, bin_seeding=True) ms.fit(X) labels = ms.labels_ cluster_centers = ms.cluster_centers_ labels_unique = np.unique(labels) n_clusters_ = len(labels_unique) print("number of estimated clusters : %d" % n_clusters_) ############################################################################### # Plot result import matplotlib.pyplot as plt from itertools import cycle plt.figure(1) plt.clf() plt.axis([0, 1024, 0, 768]) colors = cycle('bgrcmykbgrcmykbgrcmykbgrcmyk') for k, col in zip(range(n_clusters_), colors): my_members = labels == k cluster_center = cluster_centers[k] plt.plot(X[my_members, 0], X[my_members, 1], col + '.') plt.show()
------------------------------------------------------------------------------ Transform Data into Opportunity. Accelerate data analysis in your applications with Intel Data Analytics Acceleration Library. Click to learn more. http://makebettercode.com/inteldaal-eval
_______________________________________________ Scikit-learn-general mailing list Scikit-learn-general@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/scikit-learn-general