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 tqdm import trange | |
DFLT_NBOOTS=500 | |
def raw_metric_samples(metrics, *data_args, nboots=DFLT_NBOOTS, sort=False, | |
**metric_kwargs): | |
"""Return dataframe containing metric(s) for nboots boot sample datasets. | |
metrics is a metric func or iterable of funcs e.g. [m1, m2, m3] | |
""" | |
if callable(metrics): metrics=[metrics] # single metric func to list | |
metrics=list(metrics) # in case it is a generator | |
dforig=pd.DataFrame\ |
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) |