Created
August 2, 2018 14:11
-
-
Save kushalchauhan98/443c48ff4219a920be7c4035e5375b61 to your computer and use it in GitHub Desktop.
Summarize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.metrics import pairwise_distances_argmin_min | |
avg = [] | |
for j in range(n_clusters): | |
idx = np.where(kmeans.labels_ == j)[0] | |
avg.append(np.mean(idx)) | |
closest, _ = pairwise_distances_argmin_min(kmeans.cluster_centers_, encoded) | |
ordering = sorted(range(n_clusters), key=lambda k: avg[k]) | |
summary = ' '.join([email[closest[idx]] for idx in ordering]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment