SHARE
TWEET

Untitled

a guest Sep 18th, 2019 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from sklearn.cluster import KMeans
  2. import numpy as np
  3. X = np.array([[25,79,79],[34,51,51],[22,53,53],[27,78,78],[33,59,59],[33,74,74],[31,73,73]
  4.             ,[22,57,57],[35,69,69],[34,75,75],[67,51,51],[54,32,32],[57,40,40],[43,47,47]
  5.             ,[50,53,53],[57,36,57],[59,35,59],[52,58,52],[65,59,65],[47,50,47],[49,25,49]
  6.             ,[48,20,48],[35,14,35],[33,12,33],[44,20,44],[45,5,45],[38,29,38],[43,27,43]
  7.             ,[51,8,51],[46,7,46]])
  8.  
  9. centro=np.array([[10,50,75],[11,60,55],[2,30,31]])
  10. kmeans = KMeans(n_clusters=3, init=centro).fit(X)
  11. #kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
  12. print (kmeans.labels_)
  13.  
  14. print (kmeans.predict([[12,3,5],[0,0,0]]))
  15.  
  16. print (kmeans.cluster_centers_)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top