Belle II Software light-2405-quaxo
RejectionOverEfficiency Class Reference
Inheritance diagram for RejectionOverEfficiency:
Collaboration diagram for RejectionOverEfficiency:

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 rejection over the efficiency also known as ROC curve

Definition at line 425 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 434 of file plotting.py.

434 def add(self, data, column, signal_mask, bckgrd_mask, weight_column=None, label=None):
435 """
436 Add a new curve to the ROC plot
437 @param data pandas.DataFrame containing all data
438 @param column which is used to calculate efficiency and purity for different cuts
439 @param signal_mask boolean numpy.array defining which events are signal events
440 @param bckgrd_mask boolean numpy.array defining which events are background events
441 @param weight_column column in data containing the weights for each event
442 """
443 hists = histogram.Histograms(data, column, {'Signal': signal_mask, 'Background': bckgrd_mask}, weight_column=weight_column)
444 efficiency, efficiency_error = hists.get_efficiency(['Signal'])
445 rejection, rejection_error = hists.get_efficiency(['Background'])
446 rejection = 1 - rejection
447 if isinstance(efficiency, int) and not isinstance(rejection, int):
448 efficiency = numpy.array([efficiency] * len(rejection))
449 elif isinstance(rejection, int) and not isinstance(efficiency, int):
450 rejection = numpy.array([rejection] * len(efficiency))
451 elif isinstance(rejection, int) and isinstance(efficiency, int):
452 efficiency = numpy.array([efficiency])
453 rejection = numpy.array([rejection])
454
455 self.xmin, self.xmax = numpy.nanmin([efficiency.min(), self.xmin]), numpy.nanmax([efficiency.max(), self.xmax])
456 self.ymin, self.ymax = numpy.nanmin([rejection.min(), self.ymin]), numpy.nanmax([rejection.max(), self.ymax])
457
458 auc = numpy.abs(numpy.trapz(rejection, efficiency))
459
460 p = self._plot_datapoints(self.axis, efficiency, rejection, xerr=efficiency_error, yerr=rejection_error)
461 self.plots.append(p)
462 if label is not None:
463 self.labels.append(label[:10] + f" ({auc:.2f})")
464 else:
465 self.labels.append(column[:10] + f" ({auc:.2f})")
466 return self
467

◆ finish()

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

Reimplemented from Plotter.

Definition at line 468 of file plotting.py.

468 def finish(self):
469 """
470 Sets limits, title, axis-labels and legend of the plot
471 """
472 self.axis.set_xlim((self.xmin, self.xmax))
473 self.axis.set_ylim((self.ymin, self.ymax))
474 self.axis.set_title("ROC Rejection Plot")
475 self.axis.get_xaxis().set_label_text('Signal Efficiency')
476 self.axis.get_yaxis().set_label_text('Background Rejection')
477 self.axis.legend([x[0] for x in self.plots], self.labels, loc='best', fancybox=True, framealpha=0.5)
478 return self
479
480

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 455 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 456 of file plotting.py.


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