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

Public Member Functions

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

Public Attributes

 xmax
 Maximum x value.
 
 ymax
 Maximum y value.
 

Detailed Description

Plots the purity over the efficiency also known as ROC curve

Definition at line 386 of file plotting.py.

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  signal_mask,
  bckgrd_mask,
  weight_column = None,
  label = None 
)
Add a new curve to the ROC 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 395 of file plotting.py.

395 def add(self, data, column, signal_mask, bckgrd_mask, weight_column=None, label=None):
396 """
397 Add a new curve to the ROC plot
398 @param data pandas.DataFrame containing all data
399 @param column which is used to calculate efficiency and purity for different cuts
400 @param signal_mask boolean numpy.array defining which events are signal events
401 @param bckgrd_mask boolean numpy.array defining which events are background events
402 @param weight_column column in data containing the weights for each event
403 """
404 hists = histogram.Histograms(data, column, {'Signal': signal_mask, 'Background': bckgrd_mask}, weight_column=weight_column)
405 efficiency, efficiency_error = hists.get_efficiency(['Signal'])
406 purity, purity_error = hists.get_purity(['Signal'], ['Background'])
407
408 self.xmin, self.xmax = numpy.nanmin([efficiency.min(), self.xmin]), numpy.nanmax([efficiency.max(), self.xmax])
409 self.ymin, self.ymax = numpy.nanmin([numpy.nanmin(purity), self.ymin]), numpy.nanmax([numpy.nanmax(purity), self.ymax])
410
411 p = self._plot_datapoints(self.axis, efficiency, purity, xerr=efficiency_error, yerr=purity_error)
412 self.plots.append(p)
413 if label is not None:
414 self.labels.append(label)
415 else:
416 self.labels.append(column)
417 return self
418

◆ finish()

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

Reimplemented from Plotter.

Definition at line 419 of file plotting.py.

419 def finish(self):
420 """
421 Sets limits, title, axis-labels and legend of the plot
422 """
423 self.axis.set_xlim((self.xmin, self.xmax))
424 self.axis.set_ylim((self.ymin, self.ymax))
425 self.axis.set_title("ROC Purity Plot")
426 self.axis.get_xaxis().set_label_text('Efficiency')
427 self.axis.get_yaxis().set_label_text('Purity')
428 self.axis.legend([x[0] for x in self.plots], self.labels, loc='best', fancybox=True, framealpha=0.5)
429 return self
430
431

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 408 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 409 of file plotting.py.


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