Kmeans Flashcards
1
Q
train a model with n clusters, using df ‘x’
A
kmeans = KMeans(n)
kmeans.fit(x)
2
Q
see which cluster each data point in ‘x’ is assigned
A
identified_clusters = kmeans.fit_predict(x) df['Cluster'] = identified_clusters
3
Q
what is the measure to use to determine number of k? what is it called? What’s the code?
A
kmeans.inertia_