sig_dataDev=dataDev[dataDev.category==1] bkg_dataDev=dataDev[dataDev.category==0] sig_dataVal=dataVal[dataVal.category==1] bkg_dataVal=dataVal[dataVal.category==0] fomEvo = [] fomCut = [] bkgEff = [] sigEff = [] sig_Init = dataVal[dataVal.category == 1].weight.sum() * 35866 * 2 bkg_Init = dataVal[dataVal.category == 0].weight.sum() * 35866 * 2 for cut in np.arange(0.0, 0.9999, 0.001): sig, bkg = getYields(dataVal, cut=cut, luminosity=luminosity) if sig[0] > 0 and bkg[0] > 0: fom, fomUnc = FullFOM(sig, bkg) fomEvo.append(fom) fomCut.append(cut) bkgEff.append(bkg[0]/bkg_Init) sigEff.append(sig[0]/sig_Init) print "Plotting" plt.figure(figsize=(7,6)) plt.hist(sig_dataDev["NN"], 50, facecolor='blue', alpha=0.7, normed=1, weights=sig_dataDev["weight"]) plt.hist(bkg_dataDev["NN"], 50, facecolor='red', alpha=0.7, normed=1, weights=bkg_dataDev["weight"]) plt.hist(sig_dataVal["NN"], 50, color='blue', alpha=1, normed=1, weights=sig_dataVal["weight"], histtype="step") plt.hist(bkg_dataVal["NN"], 50, color='red', alpha=1, normed=1, weights=bkg_dataVal["weight"], histtype="step") plt.xlabel('NN output')
scoreDev = model.evaluate(XDev, YDev, sample_weight=weightDev, verbose=0) scoreVal = model.evaluate(XVal, YVal, sample_weight=weightVal, verbose=0) print "" cohen_kappa = cohen_kappa_score(YVal, valPredict.round()) print "Calculating parameters" dataDev["NN"] = devPredict dataVal["NN"] = valPredict sig_dataDev = dataDev[dataDev.category == 1] bkg_dataDev = dataDev[dataDev.category == 0] sig_dataVal = dataVal[dataVal.category == 1] bkg_dataVal = dataVal[dataVal.category == 0] tmpSig, tmpBkg = getYields(dataVal) sigYield, sigYieldUnc = tmpSig bkgYield, bkgYieldUnc = tmpBkg fomEvo = [] fomCut = [] bkgEff = [] sigEff = [] sig_Init = dataVal[dataVal.category == 1].weight.sum() * 35866 * 2 bkg_Init = dataVal[dataVal.category == 0].weight.sum() * 35866 * 2 for cut in np.arange(0.0, 0.9999, 0.001): sig, bkg = getYields(dataVal, cut=cut, luminosity=luminosity) if sig[0] > 0 and bkg[0] > 0:
devPredict = model.predict(XDev) valPredict = model.predict(XVal) #Getting scores if args.verbose: print("Getting scores") scoreDev = model.evaluate(XDev, YDev, sample_weight=weightDev, verbose = 0) scoreVal = model.evaluate(XVal, YVal, sample_weight=weightVal, verbose = 0) # CAlculating FOM if args.verbose: print "Calculating FOM:" dataVal["NN"] = valPredict tmpSig, tmpBkg = getYields(dataVal) sigYield, sigYieldUnc = tmpSig bkgYield, bkgYieldUnc = tmpBkg sigDataVal = dataVal[dataVal.category==1] bkgDataVal = dataVal[dataVal.category==0] fomEvo = [] fomCut = [] for cut in np.arange(0.0, 0.9999999, 0.001): sig, bkg = getYields(dataVal, cut=cut) if sig[0] > 0 and bkg[0] > 0: fom, fomUnc = FullFOM(sig, bkg) fomEvo.append(fom) fomCut.append(cut)