Beispiel #1
0
if __name__ == "__main__":

    path = "/Users/musthero/Documents/Yura/Applications/tmva_local/BDT_score_distributions_electrons.root"
    hsig_path = "histo_tmva_sig"
    hbkg_path = "histo_tmva_bkg"

    rootfile = ROOT.TFile.Open(path)

    if rootfile.IsZombie():
        print "Root file is corrupt"

    hSig = rootfile.Get(hsig_path)
    hBkg = rootfile.Get(hbkg_path)

    g = build_roc(hSig, hBkg, 1)
    ll = [g]

    g.SetLineColor(ROOT.kBlue)
    g.Draw("AL") # draw TGraph with no marker dots


    # Draw rectangular cuts


    eff_rej = (0.889199,0.898912,0.000337,0.001671)
    sig_eff_val = array('f', [eff_rej[0]])
    sig_eff_err = array('f', [eff_rej[1]])
    bkg_rej_val = array('f', [eff_rej[2]])
    bkg_rej_err = array('f', [eff_rej[3]])
Beispiel #2
0
    rootfile = ROOT.TFile.Open(path)

    if rootfile.IsZombie():
        print "Root file is corrupt"

    hSig_skTMVA = rootfile.Get(hsig_skTMVA_path)
    hBkg_skTMVA = rootfile.Get(hbkg_skTMVA_path)
    hSig_sklearn = rootfile.Get(hsig_sklearn_path)
    hBkg_sklearn = rootfile.Get(hbkg_sklearn_path)

    # Stack for keeping plots
    plots = []

    # Getting ROC-curve for skTMVA
    g1 = build_roc(hSig_skTMVA, hBkg_skTMVA)
    g1.SetName("g1")
    g1.SetTitle("ROC curve [electrons]")
    plots.append(g1)

    g1.SetLineColor(ROOT.kBlue)
    g1.Draw("AL")  # draw TGraph with no marker dots

    # Getting ROC-curve for sklearn
    g2 = build_roc(hSig_sklearn, hBkg_sklearn)
    g2.SetName("g2")
    g2.SetTitle("ROC curve [electrons]")
    plots.append(g2)

    g2.SetLineStyle(7)
    g2.SetLineColor(ROOT.kRed)
Beispiel #3
0
sig_eff = array.array('f', [rate for rate in tpr])
bkg_rej = array.array('f', [(1 - rate) for rate in fpr])

# roc_curve_sk() - skTMVA version of roc_curve
from mva_tools.build_roc_simple import roc_curve_sk
fpr_comp, tpr_comp, _ = roc_curve_sk(y_test, sk_y_predicted)

sig_eff_comp = array.array('f', [rate for rate in tpr_comp])
bkg_rej_comp = array.array('f', [(1 - rate) for rate in fpr_comp])

# Stack for keeping plots
plots = []

# Getting ROC-curve for skTMVA
g1 = build_roc(histo_tmva_sig, histo_tmva_bkg)
g1.SetName("g1")
g1.SetTitle("skTMVA ROC curve [electrons]")
plots.append(g1)

g1.SetLineColor(8)  # Green color
g1.Draw("AL")  # draw TGraph with no marker dots

# Getting ROC-curve for sklearn
g2 = ROOT.TGraph(len(tpr), sig_eff, bkg_rej)
g2.GetXaxis().SetRangeUser(0.0, 1.0)
g2.GetYaxis().SetRangeUser(0.0, 1.0)
g2.SetName("g2")
g2.SetTitle("scikitlearn ROC curve [electrons]")
plots.append(g2)
    if rootfile.IsZombie():
        print "Root file is corrupt"

    hSig_skTMVA = rootfile.Get(hsig_skTMVA_path)
    hBkg_skTMVA = rootfile.Get(hbkg_skTMVA_path)
    hSig_sklearn = rootfile.Get(hsig_sklearn_path)
    hBkg_sklearn = rootfile.Get(hbkg_sklearn_path)



    # Stack for keeping plots
    plots = []

    # Getting ROC-curve for skTMVA
    g1 = build_roc(hSig_skTMVA, hBkg_skTMVA)
    g1.SetName("g1")
    g1.SetTitle("ROC curve [muons]")
    plots.append(g1)

    g1.SetLineColor(ROOT.kBlue)
    g1.Draw("AL") # draw TGraph with no marker dots

    # Getting ROC-curve for sklearn
    g2 = build_roc(hSig_sklearn, hBkg_sklearn)
    g2.SetName("g2")
    g2.SetTitle("ROC curve [muons]")
    plots.append(g2)

    g2.SetLineStyle(7)
    g2.SetLineColor(ROOT.kRed)
# roc_curve_sk() - skTMVA version of roc_curve
from mva_tools.build_roc_simple import roc_curve_sk

fpr_comp, tpr_comp, _ = roc_curve_sk(y_test, sk_y_predicted)


sig_eff_comp = array.array("f", [rate for rate in tpr_comp])
bkg_rej_comp = array.array("f", [(1 - rate) for rate in fpr_comp])


# Stack for keeping plots
plots = []

# Getting ROC-curve for skTMVA
g1 = build_roc(histo_tmva_sig, histo_tmva_bkg)
g1.SetName("g1")
g1.SetTitle("skTMVA ROC curve [electrons]")
plots.append(g1)

g1.SetLineColor(8)  # Green color
g1.Draw("AL")  # draw TGraph with no marker dots

# Getting ROC-curve for sklearn
g2 = ROOT.TGraph(len(tpr), sig_eff, bkg_rej)
g2.GetXaxis().SetRangeUser(0.0, 1.0)
g2.GetYaxis().SetRangeUser(0.0, 1.0)
g2.SetName("g2")
g2.SetTitle("scikitlearn ROC curve [electrons]")
plots.append(g2)