Created
July 10, 2019 16:57
-
-
Save amorgun/2d7fdcaff62fab35a573a5888f11d849 to your computer and use it in GitHub Desktop.
Pretty print confusion matrix
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
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