X-Git-Url: http://plrg.eecs.uci.edu/git/?p=pingpong.git;a=blobdiff_plain;f=python_ml%2Fplotting.py;h=0089d021dfc629c1b31e0f25dad689d76826ba54;hp=526bf8c4327ee811975e8aad0087e0f131347fcc;hb=b160880bf9d2a6cca47bcc06c63680f75073a6f4;hpb=ad218aaf80ad78427de84f09709f04739b0a04c1;ds=sidebyside diff --git a/python_ml/plotting.py b/python_ml/plotting.py index 526bf8c..0089d02 100644 --- a/python_ml/plotting.py +++ b/python_ml/plotting.py @@ -27,14 +27,14 @@ with open(path + filename, "r") as pairs: #print(pairsArr) X = np.array(pairsArr); -clusters = 9 +clusters = 6 # Plot the data points based on the clusters clusterer = KMeans(n_clusters=clusters, random_state=10) cluster_labels = clusterer.fit_predict(X) # 2nd Plot showing the actual clusters formed colors = cm.nipy_spectral(cluster_labels.astype(float) / clusters) -ax2.scatter(X[:, 0], X[:, 1], marker='o', s=100, lw=0, alpha=0.3, +ax2.scatter(X[:, 0], X[:, 1], marker='o', s=50, lw=0, alpha=0.3, c=colors, edgecolor='k') # Labeling the clusters @@ -43,6 +43,7 @@ centers = clusterer.cluster_centers_ for i, c in enumerate(centers): mark = '[' + str(int(c[0])) + ', ' + str(int(c[1])) + ']' + ', ' + str(clusterer.labels_.tolist().count(i)) ax2.scatter(c[0], c[1], marker='$%s$' % mark, alpha=1, s=3000, edgecolor='k') + print('[' + str(int(c[0])) + ', ' + str(int(c[1])) + ']' + ', ' + str(clusterer.labels_.tolist().count(i))) ax2.set_title("The visualization of the clustered data.") ax2.set_xlabel("Feature space for the 1st feature")