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

Public Member Functions

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

Public Attributes

 xmax
 Maximum x value.
 
 ymax
 Maximum y value.
 

Detailed Description

Plots the purity in each bin over the classifier output.

Definition at line 533 of file plotting.py.

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  signal_mask,
  bckgrd_mask,
  weight_column = None 
)
Add a new curve to the Diagonal plot
@param data pandas.DataFrame containing all data
@param column which is used to calculate 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 542 of file plotting.py.

542 def add(self, data, column, signal_mask, bckgrd_mask, weight_column=None):
543 """
544 Add a new curve to the Diagonal plot
545 @param data pandas.DataFrame containing all data
546 @param column which is used to calculate purity for different cuts
547 @param signal_mask boolean numpy.array defining which events are signal events
548 @param bckgrd_mask boolean numpy.array defining which events are background events
549 @param weight_column column in data containing the weights for each event
550 """
551 hists = histogram.Histograms(data, column, {'Signal': signal_mask, 'Background': bckgrd_mask}, weight_column=weight_column)
552 purity, purity_error = hists.get_purity_per_bin(['Signal'], ['Background'])
553
554 self.xmin, self.xmax = min(hists.bin_centers.min(), self.xmin), max(hists.bin_centers.max(), self.xmax)
555 # self.ymin, self.ymax = numpy.nanmin([numpy.nanmin(purity), self.ymin]), numpy.nanmax([numpy.nanmax(purity), self.ymax])
556 self.ymin, self.ymax = 0, 1
557
558 p = self._plot_datapoints(self.axis, hists.bin_centers, purity, xerr=hists.bin_widths / 2.0, yerr=purity_error)
559 self.plots.append(p)
560 self.labels.append(column)
561 return self
562

◆ finish()

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

Reimplemented from Plotter.

Definition at line 563 of file plotting.py.

563 def finish(self):
564 """
565 Sets limits, title, axis-labels and legend of the plot
566 """
567 self.scale_limits()
568 self.axis.plot((0.0, 1.0), (0.0, 1.0), color='black')
569 self.axis.set_xlim((self.xmin, self.xmax))
570 self.axis.set_ylim((self.ymin, self.ymax))
571 self.axis.set_title("Diagonal Plot")
572 self.axis.get_xaxis().set_label_text('Classifier Output')
573 self.axis.get_yaxis().set_label_text('Purity Per Bin')
574 self.axis.legend([x[0] for x in self.plots], self.labels, loc='best', fancybox=True, framealpha=0.5)
575 return self
576
577
Definition: plot.py:1

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 554 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 556 of file plotting.py.


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