16 This class provides a fast implementation of equal frequency binning.
17 In Equal frequency binning the binning is chosen in a way that every bin has the same number of entries.
18 An example with a Neural Network can be found in: mva/examples/keras/preprocessing.py
24 If you saved a state before and wants to rebuild the class use the state parameter.
28 self.
statestate = {
'binning_array': [],
'number_of_bins': 0}
30 self.
statestate = state
32 def fit(self, x, number_of_bins=100):
34 Do the fitting -> calculate binning boundaries
36 for variable
in range(len(x[0, :])):
37 self.
statestate[
'binning_array'].append(np.percentile(np.nan_to_num(x[:, variable]),
38 np.linspace(0, 100, number_of_bins + 1)))
39 self.
statestate[
'number_of_bins'] = number_of_bins
45 for variable
in range(len(x[0, :])):
46 x[:, variable] = np.digitize(np.nan_to_num(x[:, variable]),
47 self.
statestate[
'binning_array'][variable][1:-1]) / self.
statestate[
'number_of_bins']
52 Returns a pickable dictionary to save the state of the class in a mva weightfile
54 return self.
statestate
def fit(self, x, number_of_bins=100)
def __init__(self, state=None)