Last active
September 27, 2021 22:10
-
-
Save DavidRosen/2bc1ebe57c98e7edf579e314bab05d76 to your computer and use it in GitHub Desktop.
Imbalanced Data article
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
hardpredtst=gbc.predict(Xtest) | |
def conf_matrix(y,pred): | |
((tn, fp), (fn, tp)) = metrics.confusion_matrix(y, pred) | |
((tnr,fpr),(fnr,tpr))= metrics.confusion_matrix(y, pred, normalize='true') | |
return pd.DataFrame([[f'TN = {tn} (TNR = {tnr:1.2%})', f'FP = {fp} (FPR = {fpr:1.2%})'], # 97 | |
[f'FN = {fn} (FNR = {fnr:1.2%})', f'TP = {tp} (TPR = {tpr:1.2%})']],#96 | |
index=['True 0(Legit)', 'True 1(Fraud)'], | |
columns=['Pred 0(Approve as Legit)', 'Pred 1(Deny as Fraud)']) | |
conf_matrix(ytest,hardpredtst) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment