K-Means Model with 4 Clusters
Let's try to improve clustering results using the split on 4 separate clusters.
Tarefa
Swipe to start coding
- Evaluate the
KMeans
with 4 clusters. - Fit the algorithm.
Solução
99
1
2
3
4
5
6
7
8
9
10
kmeans = KMeans(n_clusters=4, random_state=0)
kmeans.fit(X)
# check how many of the samples were correctly labeled
labels = kmeans.labels_
correct_labels = sum(y == labels)
print("Result: %d out of %d samples were correctly labeled." % (correct_labels, y.size))
print("Accuracy score: {0:0.2f}". format(correct_labels/float(y.size)))
Congratulations on completing the Clustering Project!
Mark tasks as Completed
Tudo estava claro?
Obrigado pelo seu feedback!
Seção 1. Capítulo 11
Pergunte à IA
Pergunte o que quiser ou experimente uma das perguntas sugeridas para iniciar nosso bate-papo