def calculateAuc(): high_mcc_diff = h5py.File('/ddnB/work/jaydy/dat/output/linr_out/08ff_all_decoy.h5')['/gaussian_nb/high/high_mcc_diff'][()] low_mcc_diff = h5py.File('/ddnB/work/jaydy/dat/output/linr_out/08ff_all_decoy.h5')['/gaussian_nb/low/low_mcc_diff'][()] import NB_classifier as nb TPRs, FPRs = nb.constructRoc(low_mcc_diff[:, 1], high_mcc_diff[:, 1]) import numpy as np auc = np.trapz(TPRs, x=FPRs) print "AUC\t: ", auc
def weightDiff(likelihood_diff_high, likelihood_diff_low, weights): likelihood_diff_low = np.dot(likelihood_diff_low, weights) likelihood_diff_high = np.dot(likelihood_diff_high, weights) return likelihood_diff_high, likelihood_diff_low if __name__ == '__main__': condi_dist_fn = 'low.dist' sub_path = 'noncentralized_path/low_decoy' buildPdf(condi_dist_fn, sub_path) condi_dist_fn = 'high.dist' sub_path = 'noncentralized_path/high_decoy' buildPdf(condi_dist_fn, sub_path) likelihood_diff_high, likelihood_diff_low = calculateLikelihoodDiff() weights_fn = '/work/jaydy/working/nb_ff_running/even_weight.txt' weights = np.loadtxt(weights_fn) likelihood_diff_high, likelihood_diff_low = weightDiff(likelihood_diff_high, likelihood_diff_low, weights) TPRs, FPRs = nb.constructRoc(likelihood_diff_high, likelihood_diff_low) auc = np.trapz(TPRs, x=FPRs) print "AUC\t: ", auc