“Kmeans Sklearn” Respostas de código

Kmeans Sklearn

from sklearn.cluster import KMeans
import numpy as np
X = np.array([[1, 2], [1, 4], [1, 0],
              [10, 2], [10, 4], [10, 0]])
kmeans = KMeans(n_clusters=2, random_state=0).fit(X)
kmeans.labels_

kmeans.predict([[0, 0], [12, 3]])

kmeans.cluster_centers_
Strange Spider

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')
Muhammad Usman Shakeel

Respostas semelhantes a “Kmeans Sklearn”

Perguntas semelhantes a “Kmeans Sklearn”

Procure respostas de código populares por idioma

Procurar outros idiomas de código