in lib/analysis.py [0:0]
def processCategoricalHistogramData(self, hist, data, branch, segment):
hist_name = hist.split('.')[-1]
print(f" processing categorical histogram: {hist}")
desc = self.config["histograms"][hist]["desc"]
labels = data[branch][segment]["histograms"][hist]["bins"]
counts = data[branch][segment]["histograms"][hist]["counts"]
self.results[branch][segment]["histograms"][hist_name]["desc"] = desc
self.results[branch][segment]["histograms"][hist_name]["labels"] = labels
self.results[branch][segment]["histograms"][hist_name]["counts"] = counts
total = sum(counts)
self.results[branch][segment]["histograms"][hist_name]["sum"] = total
ratios = [x/total for x in counts]
self.results[branch][segment]["histograms"][hist_name]["ratios"] = ratios
if branch != self.control:
ratios_control = self.results[self.control][segment]["histograms"][hist_name]["ratios"]
uplift = []
for i in range(len(ratios)):
uplift.append((ratios[i]-ratios_control[i])*100)
self.results[branch][segment]["histograms"][hist_name]["uplift"] = uplift