Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created December 4, 2020 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/fee6cb0a3a4710eb28ed48289f6c809e to your computer and use it in GitHub Desktop.
Save amankharwal/fee6cb0a3a4710eb28ed48289f6c809e to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()
labels_true = le.fit_transform(data['Revenue'])
# get predicted clustering result label
labels_pred = y_means
# print adjusted rand index, which measures the similarity of the two assignments
from sklearn import metrics
score = metrics.adjusted_rand_score(labels_true, labels_pred)
print("Adjusted rand index: ")
print(score)
# print confusion matrix
#cm = metrics.plot_confusion_matrix(None, labels_true, labels_pred)
#print(cm)
import scikitplot as skplt
plt_1 = skplt.metrics.plot_confusion_matrix(labels_true, labels_pred, normalize=False)
plt_2 = skplt.metrics.plot_confusion_matrix(labels_true, labels_pred, normalize=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment