From 81c22055437b03de2a18951e5eccc875ef2c39ff Mon Sep 17 00:00:00 2001 From: Sheng Kung Yi Date: Mon, 19 Oct 2015 17:54:03 -0700 Subject: [PATCH] revert to base state previous commit accidentally included solution, reverting to original state --- k_means/k_means_cluster.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/k_means/k_means_cluster.py b/k_means/k_means_cluster.py index f4d9c9e6445..6a2ba687017 100644 --- a/k_means/k_means_cluster.py +++ b/k_means/k_means_cluster.py @@ -62,26 +62,15 @@ def Draw(pred, features, poi, mark_poi=False, name="image.png", f1_name="feature plt.scatter( f1, f2 ) plt.show() +### cluster here; create predictions of the cluster labels +### for the data and store them to a list called pred -from sklearn.cluster import KMeans -features_list = ["poi", feature_1, feature_2] -data2 = featureFormat(data_dict, features_list ) -poi, finance_features = targetFeatureSplit( data2 ) -clf = KMeans(n_clusters=2) -pred = clf.fit_predict( finance_features ) -Draw(pred, finance_features, poi, name="clusters_before_scaling.pdf", f1_name=feature_1, f2_name=feature_2) - -### cluster here; create predictions of the cluster labels -### for the data and store them to a list called pred +### rename the "name" parameter when you change the number of features +### so that the figure gets saved to a different file try: Draw(pred, finance_features, poi, mark_poi=False, name="clusters.pdf", f1_name=feature_1, f2_name=feature_2) except NameError: print "no predictions object named pred found, no clusters to plot" - - - - -