in data_measurements/labels/labels.py [0:0]
def make_label_fig(label_results, chart_type="pie"):
try:
label_names = label_results[LABEL_NAMES]
label_measurement = label_results[LABEL_MEASUREMENT]
label_sums = label_measurement[EVAL_LABEL_SUM]
if chart_type == "bar":
fig_labels = plt.bar(
label_measurement[EVAL_LABEL_MEASURE][EVAL_LABEL_ID],
label_measurement[EVAL_LABEL_MEASURE][EVAL_LABEL_FRAC])
else:
if chart_type != "pie":
logs.info("Oops! Don't have that chart-type implemented.")
logs.info("Making the default pie chart")
# IMDB - unsupervised has a labels column where all values are -1,
# which breaks the assumption that
# the number of label_names == the number of label_sums.
# This handles that case, assuming it will happen in other datasets.
if len(label_names) != len(label_sums):
logs.warning("Can't make a figure with the given label names: "
"We don't have the right amount of label types "
"to apply them to!")
return False
fig_labels = px.pie(names=label_names, values=label_sums)
except KeyError:
logs.info("Input label data missing required key(s).")
logs.info("We require %s, %s" % (LABEL_NAMES, LABEL_MEASUREMENT))
logs.info("We found: %s" % ",".join(label_results.keys()))
return False
return fig_labels