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

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 276 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 285 of file plotting.py.

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

◆ finish()

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

Reimplemented from Plotter.

Definition at line 326 of file plotting.py.

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

Member Data Documentation

◆ xmax

xmax

Maximum x value.

Definition at line 306 of file plotting.py.

◆ ymax

ymax

Maximum y value.

Definition at line 307 of file plotting.py.


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