ROOT.gStyle.SetOptTitle(0) from utils import get_hists from rplot.rdir import Rdir fnames = [f[0]['file'] for f in rfiles] rpath_tool = Rdir(fnames) def _filter(string): matches = ['MVA_{}{}'.format(cl, string) for cl in classifiers] return lambda k: k.GetName() in matches rocs = [] for i, rfileconf in enumerate(rfiles): # roc curve: MVA_<name>_rejBvsS roc = get_hists(classifiers, rfileconf, rpath_tool, robj_t=ROOT.TH1, robj_p=_filter('_rejBvsS')) roc = dict((k, v[0]) for k, v in roc.iteritems()) # cleanup dict rocs.append(roc) # config axis_range = options.axis_range doprint = options.doprint if options.usempl: # Matplotlib import matplotlib.pyplot as plt plt.rc('font', family='Liberation Sans') # choose font plt.rc('mathtext', default='regular') # use default font for math # ROOT to Matplotlib translation layer import rootpy.plotting.root2matplotlib as rplt
if not fnmatchcase(key, clnameglob): del classifiers[key] from fixes import ROOT if batch: ROOT.gROOT.SetBatch(True) from utils import get_hists from rplot.rplot import Rplot, arrange def _filter(string): matches = ['MVA_{}{}'.format(cl, string) for cl in classifiers] return lambda k: k.GetName() in matches _filter1 = lambda string: lambda k: _filter(string+'_S')(k) or _filter(string+'_B')(k) _filter2 = lambda str1, str2: lambda k: _filter1(str1)(k) or _filter1(str2)(k) distribs = get_hists(classifiers, rfileconf, rpath_tool, robj_t = ROOT.TH1, robj_p = _filter2('', '_Train')) if rarity: rarity = get_hists(classifiers, rfileconf, rpath_tool, robj_t = ROOT.TH1, robj_p = _filter1('_Rarity')) if probab: probab = get_hists(classifiers, rfileconf, rpath_tool, robj_t = ROOT.TH1, robj_p = _filter1('_Proba')) plotter = Rplot(1, 1, 800, 600) plotter.alpha = 0.2 plotter.fill_colours = (ROOT.kAzure, ROOT.kRed, ROOT.kAzure, ROOT.kRed) plotter.line_colours = (ROOT.kAzure-6, ROOT.kRed+2, ROOT.kAzure-6, ROOT.kRed+2) plotter.markers = (ROOT.kPlus, ROOT.kPlus, ROOT.kPlus, ROOT.kPlus) canvas = plotter.prep_canvas() if doprint: canvas.Print('overtraining.pdf[')
from rplot.rdir import Rdir fnames = [f[0]['file'] for f in rfiles] rpath_tool = Rdir(fnames) def _filter(string): matches = ['MVA_{}{}'.format(cl, string) for cl in classifiers] return lambda k: k.GetName() in matches rocs = [] for i, rfileconf in enumerate(rfiles): # roc curve: MVA_<name>_rejBvsS roc = get_hists(classifiers, rfileconf, rpath_tool, robj_t=ROOT.TH1, robj_p=_filter('_rejBvsS')) roc = dict((k, v[0]) for k, v in roc.iteritems()) # cleanup dict rocs.append(roc) # config axis_range = options.axis_range doprint = options.doprint if options.usempl: # Matplotlib import matplotlib.pyplot as plt plt.rc('font', family='Liberation Sans') # choose font plt.rc('mathtext', default='regular') # use default font for math
for key in transforms: if not fnmatchcase(key, options.transglob): del transforms[key] from fixes import ROOT ROOT.gROOT.SetBatch(options.batch) ROOT.gStyle.SetOptTitle(options.title) from utils import get_hists from rplot.rplot import Rplot, arrange, partition ## variable distributions if options.distribs: # histogram order: signal, background (repeat for diff transforms) distributions = get_hists(transforms, rfileconf, pathtool, robj_t=ROOT.TH1) ROOT.gStyle.SetHatchesLineWidth(1) ROOT.gStyle.SetHatchesSpacing(2.5) for transform in transforms: def _style(l): # l.reverse() l[0].SetFillStyle(3345) l[1].SetFillStyle(3354) distributions[transform] = arrange(distributions[transform], 2, predicate=_style) plotter = Rplot(3, 3, 2000, 1200) plotter.alpha = 0.2 canvas = plotter.prep_canvas() if options.doprint:
from utils import get_hists from rplot.rplot import Rplot, arrange def _filter(string): matches = ['MVA_{}{}'.format(cl, string) for cl in classifiers] return lambda k: k.GetName() in matches _filter1 = lambda string: lambda k: _filter(string + '_S')(k) or _filter( string + '_B')(k) _filter2 = lambda str1, str2: lambda k: _filter1(str1)(k) or _filter1(str2)(k) distribs = get_hists(classifiers, rfileconf, rpath_tool, robj_t=ROOT.TH1, robj_p=_filter2('', '_Train')) if options.rarity: rarity = get_hists(classifiers, rfileconf, rpath_tool, robj_t=ROOT.TH1, robj_p=_filter1('_Rarity')) else: rarity = None if options.probab: probab = get_hists(classifiers, rfileconf, rpath_tool, robj_t=ROOT.TH1,