Skip to content

Instantly share code, notes, and snippets.

@DavidRosen
Last active September 27, 2021 22:10
Show Gist options
  • Save DavidRosen/2bc1ebe57c98e7edf579e314bab05d76 to your computer and use it in GitHub Desktop.
Save DavidRosen/2bc1ebe57c98e7edf579e314bab05d76 to your computer and use it in GitHub Desktop.
Imbalanced Data article
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