Belle II Software development
PurityOverEfficiency Class Reference
Inheritance diagram for PurityOverEfficiency:
Plotter

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 385 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 394 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 418 of file plotting.py.

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

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 407 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 408 of file plotting.py.


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