Belle II Software light-2406-ragdoll
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 540 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 549 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 570 of file plotting.py.

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

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 561 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 563 of file plotting.py.


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