Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

kmeans sklearn

kmean_model = KMeans(init='k-means++',n_clusters = 8,max_iter = 200,n_init=10) #here we are using the KMEANS class and configuring it's parameters such as
# initializor , total number of clusters to apply, maximum iterations and no of times to run the algorithm with different centroid seeds
kmean_model.fit(df)

print(kmean_model.cluster_centers_)
predict = kmean_model.predict(df)

plt.scatter(df.iloc[:,2],df.iloc[:,3],c = predict,cmap = 'viridis')
Source by scikit-learn.org #
 
PREVIOUS NEXT
Tagged: #kmeans #sklearn
ADD COMMENT
Topic
Name
7+6 =