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

Public Member Functions

def __init__ (self, cut_direction=1, cut_value=np.nan)
 
def cut_direction (self)
 
def cut_value (self)
 
def clone (self)
 
def determine_cut_value (self, estimates, truths)
 
def fit (self, estimates, truths)
 
def predict (self, estimates)
 
def describe (self, estimates, truths)
 

Public Attributes

 cut_direction_
 cached copy of the cut direction (< or >)
 
 cut_value_
 cached copy of the cut threshold
 

Detailed Description

Simple classifier cutting on a single variable

Definition at line 496 of file classification.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  cut_direction = 1,
  cut_value = np.nan 
)
Constructor

Reimplemented in CutAtBackgroundRejectionClassifier.

Definition at line 500 of file classification.py.

500 def __init__(self, cut_direction=1, cut_value=np.nan):
501 """Constructor"""
502
503 self.cut_direction_ = cut_direction
504
505 self.cut_value_ = cut_value
506

Member Function Documentation

◆ clone()

def clone (   self)
Return a clone of this object

Definition at line 517 of file classification.py.

517 def clone(self):
518 """Return a clone of this object"""
519 return copy.copy(self)
520

◆ cut_direction()

def cut_direction (   self)
Get the value of the cut direction

Definition at line 508 of file classification.py.

508 def cut_direction(self):
509 """Get the value of the cut direction"""
510 return self.cut_direction_
511

◆ cut_value()

def cut_value (   self)
Get the value of the cut threshold

Definition at line 513 of file classification.py.

513 def cut_value(self):
514 """Get the value of the cut threshold"""
515 return self.cut_value_
516

◆ describe()

def describe (   self,
  estimates,
  truths 
)
Describe the cut selection and its efficiency, purity and background rejection

Definition at line 542 of file classification.py.

542 def describe(self, estimates, truths):
543 """Describe the cut selection and its efficiency, purity and background rejection"""
544 if self.cut_direction_ < 0:
545 print("Cut accepts >= ", self.cut_value_, 'with')
546 else:
547 print("Cut accepts <= ", self.cut_value_, 'with')
548
549 binary_estimates = self.predict(estimates)
550
551 efficiency = scores.efficiency(truths, binary_estimates)
552 purity = scores.purity(truths, binary_estimates)
553 background_rejection = scores.background_rejection(truths, binary_estimates)
554
555 print("efficiency", efficiency)
556 print("purity", purity)
557 print("background_rejection", background_rejection)
558
559

◆ determine_cut_value()

def determine_cut_value (   self,
  estimates,
  truths 
)
Get the value of the cut threshold

Reimplemented in CutAtBackgroundRejectionClassifier.

Definition at line 521 of file classification.py.

521 def determine_cut_value(self, estimates, truths):
522 """Get the value of the cut threshold"""
523 return self.cut_value_ # do not change cut value from constructed one
524

◆ fit()

def fit (   self,
  estimates,
  truths 
)
Fit to determine the cut threshold

Definition at line 525 of file classification.py.

525 def fit(self, estimates, truths):
526 """Fit to determine the cut threshold"""
527 self.cut_value_ = self.determine_cut_value(estimates, truths)
528 return self
529

◆ predict()

def predict (   self,
  estimates 
)
Select estimates that satisfy the cut

Definition at line 530 of file classification.py.

530 def predict(self, estimates):
531 """Select estimates that satisfy the cut"""
532 if self.cut_value_ is None:
533 raise ValueError("Cut value not set. Forgot to fit?")
534
535 if self.cut_direction_ < 0:
536 binary_estimates = estimates >= self.cut_value_
537 else:
538 binary_estimates = estimates <= self.cut_value_
539
540 return binary_estimates
541

Member Data Documentation

◆ cut_direction_

cut_direction_

cached copy of the cut direction (< or >)

Definition at line 503 of file classification.py.

◆ cut_value_

cut_value_

cached copy of the cut threshold

Definition at line 505 of file classification.py.


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