Created
September 22, 2018 21:06
-
-
Save emmagrimaldi/707915f7472e9883ad75450b36b87a00 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 confusion_matrix | |
| def conf_matrix(model, X_test): | |
| y_pred = model.predict(X_test) # calculate predictions | |
| cm = confusion_matrix(y_test, y_pred) # defining the confusion matrix | |
| tn, fp, fn, tp = cm.ravel() # assigning the elements of the confusion matrix to variables | |
| print(f"True Negatives: {tn}") # print those variables | |
| print(f"False Positives: {fp}") | |
| print(f"False Negatives: {fn}") | |
| print(f"True Positives: {tp}") # return the confusion matrix as dataframe | |
| return pd.DataFrame(cm, | |
| columns = ['Pred Deep Philosophy','Pred Shower Thoughts'], | |
| index = ['Act Deep Philosphy', 'Act Shower Thoughts']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment