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

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 539 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 548 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 569 of file plotting.py.

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

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 560 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 562 of file plotting.py.


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