<jupyter_start><jupyter_text>ROC<jupyter_code>def get_tpr_fpr(sigloss,bkgloss,aetype='bkg'):
    bins = np.linspace(0,0.05,1001)
    tpr = []
    fpr = []
    for cut in bins:
        if aetype == 'sig':
            tpr.append(np.where(sigloss<cut)[0].shape[0]/len(sigloss))
            fpr.append(np.where(bkgloss<cut)[0].shape[0]/len(bkgloss))
        if aetype == 'bkg':
            tpr.append(np.where(sigloss>cut)[0].shape[0]/len(sigloss))
            fpr.append(np.where(bkgloss>cut)[0].shape[0]/len(bkgloss))
    return tpr,fpr  
tpr, fpr = get_tpr_fpr(loss_sig,loss_bkg)
plt.plot(fpr,tpr)
np.save('VanillaVAE_conventionaltau_zdim3_sigloss.npy',loss_sig)
np.save('VanillaVAE_conventionaltau_zdim3_bkgloss.npy',loss_bkg)<jupyter_output><empty_output><jupyter_text>PRECISION - RECALL<jupyter_code>def get_precision_recall(sigloss,bkgloss,aetype='bkg'):
    bins = np.linspace(0,2,1001)
    tpr = []
    fpr = []
    precision = []
    for cut in bins:
        if aetype == 'sig':
            tpr.append(np.where(sigloss<cut)[0].shape[0]/len(sigloss))
            precision.append((np.where(sigloss<cut)[0].shape[0])/(np.where(bkgloss<cut)[0].shape[0]+np.where(sigloss<cut)[0].shape[0]))
            
        if aetype == 'bkg':
            tpr.append(np.where(sigloss>cut)[0].shape[0]/len(sigloss))
            precision.append((np.where(sigloss>cut)[0].shape[0])/(np.where(bkgloss>cut)[0].shape[0]+np.where(sigloss>cut)[0].shape[0]))
    return precision,tpr      
prec, rec = get_precision_recall(loss_sig,loss_bkg)
plt.plot(rec,prec)
jnm<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1784126984126984, 'fraction_numerical': 0.025396825396825397, 'mean_word_length': 3.9559748427672954, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '269811', 'license': 'MIT', 'n_tokens_mistral': 679, 'n_tokens_neox': 644, 'n_words': 56, 'path': 'new_flows/VAE_without_Flow_conventional_taus.ipynb', 'repo_name': 'violatingcp/QUASAR', 'size': '1575'}