Belle II Software development
CutAtBackgroundRejectionClassifier Class Reference
Inheritance diagram for CutAtBackgroundRejectionClassifier:
CutClassifier

Public Member Functions

def __init__ (self, background_rejection=0.5, cut_direction=1)
 
def determine_cut_value (self, estimates, truths)
 

Public Attributes

 background_rejection
 cachec copy of the background-rejection threshold
 

Detailed Description

Apply cut on the background rejection

Definition at line 564 of file classification.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  background_rejection = 0.5,
  cut_direction = 1 
)
Constructor

Reimplemented from CutClassifier.

Definition at line 567 of file classification.py.

567 def __init__(self, background_rejection=0.5, cut_direction=1):
568 """Constructor"""
569 super().__init__(cut_direction=cut_direction, cut_value=np.nan)
570
571 self.background_rejection = background_rejection
572

Member Function Documentation

◆ determine_cut_value()

def determine_cut_value (   self,
  estimates,
  truths 
)
Find the cut value that satisfies the desired background-rejection level

Reimplemented from CutClassifier.

Definition at line 573 of file classification.py.

573 def determine_cut_value(self, estimates, truths):
574 """Find the cut value that satisfies the desired background-rejection level"""
575 n_data = len(estimates)
576 n_signals = scores.signal_amount(truths, estimates)
577 n_bkgs = n_data - n_signals
578
579 sorting_indices = np.argsort(estimates)
580 if self.cut_direction_ < 0: # reject low
581 # Keep a reference to keep the content alive
582 original_sorting_indices = sorting_indices # noqa
583 sorting_indices = sorting_indices[::-1]
584
585 sorted_truths = truths[sorting_indices]
586 sorted_estimates = estimates[sorting_indices]
587
588 sorted_n_accepted_signals = np.cumsum(sorted_truths, dtype=float)
589 # sorted_efficiencies = sorted_n_accepted_signals / n_signals
590
591 sorted_n_rejected_signals = n_signals - sorted_n_accepted_signals
592 sorted_n_rejects = np.arange(len(estimates) + 1, 1, -1)
593 sorted_n_rejected_bkgs = sorted_n_rejects - sorted_n_rejected_signals
594 sorted_bkg_rejections = sorted_n_rejected_bkgs / n_bkgs
595
596 cut_index, = np.searchsorted(sorted_bkg_rejections[::-1], (self.background_rejection,), side='right')
597
598 cut_value = sorted_estimates[-cut_index - 1]
599 return cut_value

Member Data Documentation

◆ background_rejection

background_rejection

cachec copy of the background-rejection threshold

Definition at line 571 of file classification.py.


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