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

Public Member Functions

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

Public Attributes

 xmax
 Maximum x value.
 
 ymax
 Maximum y value.
 

Detailed Description

Plots the purity and the efficiency over the cut value (for cut choosing)

Definition at line 270 of file plotting.py.

Member Function Documentation

◆ add()

def add (   self,
  data,
  column,
  signal_mask,
  bckgrd_mask,
  weight_column = None,
  normed = True 
)
Add a new curve to the 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 279 of file plotting.py.

279 def add(self, data, column, signal_mask, bckgrd_mask, weight_column=None, normed=True):
280 """
281 Add a new curve to the plot
282 @param data pandas.DataFrame containing all data
283 @param column which is used to calculate efficiency and purity for different cuts
284 @param signal_mask boolean numpy.array defining which events are signal events
285 @param bckgrd_mask boolean numpy.array defining which events are background events
286 @param weight_column column in data containing the weights for each event
287 """
288
289 hists = histogram.Histograms(data, column, {'Signal': signal_mask, 'Background': bckgrd_mask}, weight_column=weight_column)
290
291 if normed:
292 efficiency, efficiency_error = hists.get_efficiency(['Signal'])
293 purity, purity_error = hists.get_purity(['Signal'], ['Background'])
294 else:
295 efficiency, efficiency_error = hists.get_true_positives(['Signal'])
296 purity, purity_error = hists.get_false_positives(['Background'])
297
298 cuts = hists.bin_centers
299
300 self.xmin, self.xmax = numpy.nanmin([numpy.nanmin(cuts), self.xmin]), numpy.nanmax([numpy.nanmax(cuts), self.xmax])
301 self.ymin, self.ymax = numpy.nanmin([numpy.nanmin(efficiency), numpy.nanmin(purity), self.ymin]), \
302 numpy.nanmax([numpy.nanmax(efficiency), numpy.nanmax(purity), self.ymax])
303
304 self.plots.append(self._plot_datapoints(self.axis, cuts, efficiency, xerr=0, yerr=efficiency_error))
305
306 if normed:
307 self.labels.append("Efficiency")
308 else:
309 self.labels.append("True positive")
310
311 self.plots.append(self._plot_datapoints(self.axis, cuts, purity, xerr=0, yerr=purity_error))
312
313 if normed:
314 self.labels.append("Purity")
315 else:
316 self.labels.append("False positive")
317
318 return self
319

◆ finish()

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

Reimplemented from Plotter.

Definition at line 320 of file plotting.py.

320 def finish(self):
321 """
322 Sets limits, title, axis-labels and legend of the plot
323 """
324 self.axis.set_xlim((self.xmin, self.xmax))
325 self.axis.set_ylim((self.ymin, self.ymax))
326 self.axis.set_title("Classification Plot")
327 self.axis.get_xaxis().set_label_text('Cut Value')
328 self.axis.legend([x[0] for x in self.plots], self.labels, loc='best', fancybox=True, framealpha=0.5)
329 return self
330
331

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 300 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 301 of file plotting.py.


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