umami.helper_tools package#
Submodules#
umami.helper_tools.classification_tools module#
Provides methods for classification of events by flavour.
- umami.helper_tools.classification_tools.get_class_label_variables(class_labels: list)#
Returns a list of the label variables used for the provided class_labels.
- Parameters:
class_labels (list) – List with the class labels.
- Returns:
label_var_list – List with the truth label variables needed for the classes.
- Return type:
list
- umami.helper_tools.classification_tools.get_class_prob_var_names(tagger_name: str, class_labels: list)#
Returns a list of the probability variable names used for the provided class_labels.
- Parameters:
tagger_name (str) – Name of the tagger that is used e.g. dips20210729.
class_labels (list) – List with the class labels.
- Returns:
prob_var_list – List with the tagger_name and probabilites merged e.g. [“dips20210729_pb”, “dips20210729_pc”, “dips20210729_pu”].
- Return type:
list
umami.helper_tools.histogram_tools module#
Helper function for histogram handling.
- umami.helper_tools.histogram_tools.hist_ratio(numerator, denominator, numerator_unc, denominator_unc, step: bool = True)#
This method calculates the ratio of the given bincounts and returns the input for a step function that plots the ratio.
- Parameters:
numerator (array_like) – Numerator in the ratio calculation.
denominator (array_like) – Denominator in the ratio calculation.
numerator_unc (array_like) – Uncertainty of the numerator.
denominator_unc (array_like) – Uncertainty of the denominator.
step (bool) – if True duplicates first bin to match with step plotting function, by default True
- Returns:
step_ratio (array_like) – Ratio returning 1 in case the denominator is 0.
step_ratio_unc (array_like) – Stat. uncertainty of the step_ratio
- Raises:
AssertionError – If inputs don’t have the same shape.
- umami.helper_tools.histogram_tools.hist_w_unc(arr, bins, bins_range=None, normed: bool = True)#
Computes histogram and the associated statistical uncertainty.
- Parameters:
arr (array_like) – Input data. The histogram is computed over the flattened array.
bins (int or sequence of scalars or str) – bins parameter from np.histogram
bins_range (Tuple, optional) – range parameter from np.histogram
normed (bool, optional) – If True (default) the calculated histogram is normalised to an integral of 1.
- Returns:
bin_edges (array of dtype float) – Return the bin edges (length(hist)+1)
hist (numpy array) – The values of the histogram. If normed is true (default), returns the normed counts per bin
unc (numpy array) – Statistical uncertainty per bin. If normed is true (default), returns the normed values.
band (numpy array) – lower uncertainty band location: hist - unc If normed is true (default), returns the normed values.
- umami.helper_tools.histogram_tools.save_divide(numerator, denominator, default=1.0)#
Division using numpy divide function returning default value in cases where denominator is 0.
- Parameters:
numerator (array_like) – Numerator in the ratio calculation.
denominator (array_like) – Denominator in the ratio calculation.
default (float) – default value which is returned if denominator is 0.
- Returns:
ratio
- Return type:
array_like