 |
Belle II Software
release-05-01-25
|
1 """This module contains score functions to quantify the quality of a classification
3 All score function have the signature
4 def score(truths, predictions):
6 comparing the truth information against a model and return a numerical value.
13 """Score function: amount of data after a selection"""
14 n_predictions = len(predictions)
15 n_truths = len(truths)
17 if n_predictions != n_truths:
18 raise ValueError(
"Prediction and truth do not represent the same amount of data.")
24 """Score function: amount of signal of a classification"""
25 return np.count_nonzero(truths)
29 """Score function: amount accepted of a classification"""
30 return np.count_nonzero(predictions)
34 """Score function: amount of accepted signal of a classification"""
35 return np.count_nonzero(predictions * truths)
44 """Score function: amount of background of a classification"""
49 """Score function: amount rejected of a classification"""
54 """Score function: amount of rejected signal of a classification"""
59 """Score function: amount of accepted background of a classification"""
64 """Score function: amount of rejected background of a classification"""
72 """Score function: purity = accepted signal / accepted"""
77 """Score function: efficiency = accepted signal / signal"""
82 """Score function: accuracy = (accepted signal + rejected background) / total"""
85 return np.divide(1.0 * n_correct, n_data)
89 """Score function: background rejection = rejected background / background"""
92 return np.divide(1.0 * n_rejected_background, n_background)
96 """Score function: background / signal"""
99 n_background = n_data - n_signal
100 return np.divide(1.0 * n_signal, n_background)
def background_amount(truths, predictions)
def accepted_background_amount(truths, predictions)
def accepted_signal_amount(truths, predictions)
def efficiency(truths, predictions)
def rejected_background_amount(truths, predictions)
def rejected_amount(truths, predictions)
def signal_background_ratio(truths, predictions)
def data_amount(truths, predictions)
def purity(truths, predictions)
def signal_amount(truths, predictions)
def accepted_amount(truths, predictions)
def accuracy(truths, predictions)
def background_rejection(truths, predictions)
def rejected_signal_amount(truths, predictions)