Belle II Software light-2406-ragdoll
PurityAndEfficiencyOverCut Class Reference
Inheritance diagram for PurityAndEfficiencyOverCut:
Collaboration diagram for PurityAndEfficiencyOverCut:

Public Member Functions

def add (self, data, column, signal_mask, bckgrd_mask, weight_column=None, normed=True)
 
def finish (self)
 

Public Attributes

 xmax
 Maximum x value.
 
 ymax
 Maximum y value.
 

Detailed Description

Plots the purity and the efficiency over the cut value (for cut choosing)

Definition at line 277 of file plotting.py.

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  signal_mask,
  bckgrd_mask,
  weight_column = None,
  normed = True 
)
Add a new curve to the plot
@param data pandas.DataFrame containing all data
@param column which is used to calculate efficiency and purity for different cuts
@param signal_mask boolean numpy.array defining which events are signal events
@param bckgrd_mask boolean numpy.array defining which events are background events
@param weight_column column in data containing the weights for each event

Reimplemented from Plotter.

Definition at line 286 of file plotting.py.

286 def add(self, data, column, signal_mask, bckgrd_mask, weight_column=None, normed=True):
287 """
288 Add a new curve to the plot
289 @param data pandas.DataFrame containing all data
290 @param column which is used to calculate efficiency and purity for different cuts
291 @param signal_mask boolean numpy.array defining which events are signal events
292 @param bckgrd_mask boolean numpy.array defining which events are background events
293 @param weight_column column in data containing the weights for each event
294 """
295
296 hists = histogram.Histograms(data, column, {'Signal': signal_mask, 'Background': bckgrd_mask}, weight_column=weight_column)
297
298 if normed:
299 efficiency, efficiency_error = hists.get_efficiency(['Signal'])
300 purity, purity_error = hists.get_purity(['Signal'], ['Background'])
301 else:
302 efficiency, efficiency_error = hists.get_true_positives(['Signal'])
303 purity, purity_error = hists.get_false_positives(['Background'])
304
305 cuts = hists.bin_centers
306
307 self.xmin, self.xmax = numpy.nanmin([numpy.nanmin(cuts), self.xmin]), numpy.nanmax([numpy.nanmax(cuts), self.xmax])
308 self.ymin, self.ymax = numpy.nanmin([numpy.nanmin(efficiency), numpy.nanmin(purity), self.ymin]), \
309 numpy.nanmax([numpy.nanmax(efficiency), numpy.nanmax(purity), self.ymax])
310
311 self.plots.append(self._plot_datapoints(self.axis, cuts, efficiency, xerr=0, yerr=efficiency_error))
312
313 if normed:
314 self.labels.append("Efficiency")
315 else:
316 self.labels.append("True positive")
317
318 self.plots.append(self._plot_datapoints(self.axis, cuts, purity, xerr=0, yerr=purity_error))
319
320 if normed:
321 self.labels.append("Purity")
322 else:
323 self.labels.append("False positive")
324
325 return self
326

◆ finish()

def finish (   self)
Sets limits, title, axis-labels and legend of the plot

Reimplemented from Plotter.

Definition at line 327 of file plotting.py.

327 def finish(self):
328 """
329 Sets limits, title, axis-labels and legend of the plot
330 """
331 self.axis.set_xlim((self.xmin, self.xmax))
332 self.axis.set_ylim((self.ymin, self.ymax))
333 self.axis.set_title("Classification Plot")
334 self.axis.get_xaxis().set_label_text('Cut Value')
335 self.axis.legend([x[0] for x in self.plots], self.labels, loc='best', fancybox=True, framealpha=0.5)
336 return self
337
338

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 307 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 308 of file plotting.py.


The documentation for this class was generated from the following file: