Skip to content

Instantly share code, notes, and snippets.

@amorgun
Created July 10, 2019 16:57
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 amorgun/2d7fdcaff62fab35a573a5888f11d849 to your computer and use it in GitHub Desktop.
Save amorgun/2d7fdcaff62fab35a573a5888f11d849 to your computer and use it in GitHub Desktop.
Pretty print confusion matrix
def print_stats(y_true, y_pred):
print(f'Total accuracy: {accuracy_score(y_true, y_pred)}')
print()
cm = pd.DataFrame(confusion_matrix(y_true, y_pred),
columns=pd.MultiIndex.from_arrays([['not_fit', 'fit']], names=['My fit']),
index=['not_fit', 'fit'],
)
cm.index.name = 'Toloka fit'
print('Confusion matrix')
print(cm)
print()
print('Classification report')
print(classification_report(y_true, y_pred))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment