Does NLTK KMeans provide an inertia measure similar to that of sklearn?
I have used NLTK for KMeans clustering and would like to change the distance metric. Does NLTK KMeans provide an inertia measure similar to that of scikit-learn?
The code below shows how people usually calculate inertia with sklearn KMeans:
inertia = []
for n_clusters in range(2, 26, 1):
clusterer = KMeans(n_clusters=n_clusters)
preds = clusterer.fit_predict(features)
centers = clusterer.cluster_centers_
inertia.append(clusterer.inertia_)
plt.plot([i for i in range(2,26,1)], inertia, 'bx-')
plt.xlabel('k')
plt.ylabel('Sum_of_squared_distances')
plt.title('Elbow Method For Optimal k')
plt.show()