Skip to content

Commit

Permalink
revert to base state
Browse files Browse the repository at this point in the history
previous commit accidentally included solution, reverting to original state
  • Loading branch information
ShengKungYi committed Oct 20, 2015
1 parent f9c0720 commit 81c2205
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions k_means/k_means_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"





0 comments on commit 81c2205

Please sign in to comment.