Belle II Software development
GroupedDEDXEstimationTrainer Class Reference
Inheritance diagram for GroupedDEDXEstimationTrainer:
DEDXEstimationTrainer FittedGroupedDEDXEstimatorTrainer FunctionFittedGroupedDEDXEstimatorTrainer MaximumEstimatorTrainer MaximumEstimatorTrainerSQRT MedianEstimatorTrainer MedianEstimatorTrainerSQRT GaussianEstimatorTrainer GaussianEstimatorTrainerSQRT LandauEstimatorTrainer LandauEstimatorTrainerSQRT

Public Member Functions

 create_dedx_bins (self, data)
 
 create_p_bins (self, data)
 
 use_only_the_highest_values (self, data, number_of_values=None)
 
 create_fit_data (self, dedx_bin)
 
 fit_p_to_dedx_bin (self, dedx_bin)
 
 train (self, data)
 
 test (self, data)
 

Public Attributes

 dedx_estimator_function = None
 by default, the dE/dx-particle-identification trainer has not run yet
 
str dedx_column = "dedx"
 the default data column is 'dedx'
 

Static Public Attributes

int number_of_bins_in_dedx = 20
 number of dE/dx bins
 
int number_of_bins_in_p = 29
 number of track-momentum bins
 
int number_of_head_values_used_to_fit = 20
 number of head values in fit
 

Detailed Description

Train a neural network for dE/dx-based particle identification

Definition at line 42 of file train.py.

Member Function Documentation

◆ create_dedx_bins()

create_dedx_bins ( self,
data )
Construct the dE/dx bins and then populate them with the data

Definition at line 52 of file train.py.

52 def create_dedx_bins(self, data):
53 """Construct the dE/dx bins and then populate them with the data"""
54 dedx_bins = np.linspace(
55 data[
56 self.dedx_column].min(), data[
57 self.dedx_column].max(), GroupedDEDXEstimationTrainer.number_of_bins_in_dedx)
58 dedx_cuts = pd.cut(data[self.dedx_column], dedx_bins)
59 return data.groupby(dedx_cuts), dedx_bins
60

◆ create_fit_data()

create_fit_data ( self,
dedx_bin )
Fit track-momentum values

Definition at line 74 of file train.py.

74 def create_fit_data(self, dedx_bin):
75 """Fit track-momentum values"""
76 p_binned_data, p_bins = self.create_p_bins(dedx_bin)
77
78 number_of_p_values = pd.Series(p_binned_data.count().p.values, name="number_of_p_values")
79 p_bin_centers = pd.Series(0.5 * (p_bins[:-1] + p_bins[1:]), name="p_bin_centers")
80
81 all_fit_data = pd.DataFrame([number_of_p_values, p_bin_centers]).T
82 fit_data = self.use_only_the_highest_values(all_fit_data, GroupedDEDXEstimationTrainer.number_of_head_values_used_to_fit)
83
84 return fit_data
85

◆ create_p_bins()

create_p_bins ( self,
data )
Construct the momentum bins and then populate them with the data

Definition at line 61 of file train.py.

61 def create_p_bins(self, data):
62 """Construct the momentum bins and then populate them with the data"""
63 p_bins = np.linspace(data.p.min(), data.p.max(), GroupedDEDXEstimationTrainer.number_of_bins_in_p)
64 p_cuts = pd.cut(data.p, p_bins)
65 return data.groupby(p_cuts), p_bins
66

◆ fit_p_to_dedx_bin()

fit_p_to_dedx_bin ( self,
dedx_bin )
Fit the track-momentum values in the selected dE/dx bin, then train on the fitted values

Definition at line 86 of file train.py.

86 def fit_p_to_dedx_bin(self, dedx_bin):
87 """Fit the track-momentum values in the selected dE/dx bin, then train on the fitted values"""
88 fit_data = self.create_fit_data(dedx_bin)
89 return self.train_function(fit_data)
90
91

◆ test()

test ( self,
data )
inherited
Get the trained neural-network output value for test data

Reimplemented in MVADEDXEstimationTrainer.

Definition at line 34 of file train.py.

34 def test(self, data):
35 """Get the trained neural-network output value for test data"""
36 if self.dedx_estimator_function is None:
37 raise ValueError("Train the estimator first!")
38
39 return self.dedx_estimator_function(data[self.dedx_column])
40
41

◆ train()

train ( self,
data )
inherited
Train on the input data

Reimplemented in FittedGroupedDEDXEstimatorTrainer, and MVADEDXEstimationTrainer.

Definition at line 29 of file train.py.

29 def train(self, data):
30 """Train on the input data"""
31 # We have everything
32 raise NotImplementedError("Use this class as a base class only")
33
Definition train.py:1

◆ use_only_the_highest_values()

use_only_the_highest_values ( self,
data,
number_of_values = None )
Sort the data then select only the highest N values

Definition at line 67 of file train.py.

67 def use_only_the_highest_values(self, data, number_of_values=None):
68 """Sort the data then select only the highest N values"""
69 if number_of_values is None:
70 return data
71 else:
72 return data.sort("number_of_p_values", ascending=False).head(number_of_values).sort()
73

Member Data Documentation

◆ dedx_column

str dedx_column = "dedx"
inherited

the default data column is 'dedx'

Definition at line 27 of file train.py.

◆ dedx_estimator_function

dedx_estimator_function = None
inherited

by default, the dE/dx-particle-identification trainer has not run yet

Definition at line 25 of file train.py.

◆ number_of_bins_in_dedx

int number_of_bins_in_dedx = 20
static

number of dE/dx bins

Definition at line 46 of file train.py.

◆ number_of_bins_in_p

int number_of_bins_in_p = 29
static

number of track-momentum bins

Definition at line 48 of file train.py.

◆ number_of_head_values_used_to_fit

int number_of_head_values_used_to_fit = 20
static

number of head values in fit

Definition at line 50 of file train.py.


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