in src/fmeval/reporting/eval_output_cells.py [0:0]
def __init__(self, categories: List[str], scores: List[float], score_name: str, dataset_score: float, n: int = 10):
"""
:param categories: The names of the categories.
:param scores: The values of the category scores.
:param score_name: The name of the score that was computed in the evaluation.
:param dataset_score: The overall score for the dataset.
:param n: Max number of categories to display.
"""
note = (
f"The top {n} categories are displayed here. To view the remaining category scores, see the `output.json` file at your S3 output location."
if len(categories) > n
else ""
)
sorted_scores, sorted_categories = (list(l) for l in zip(*sorted(zip(scores, categories), reverse=True)))
bar_plot_origin = 0.5 if score_name == PROMPT_STEREOTYPING else 0
bar_plot = CategoryBarPlotCell(
sorted_categories[:n],
sorted_scores[:n],
score_name,
dataset_score,
height="70%",
width="70%",
origin=bar_plot_origin,
)
lowest_category = (
CategoryScoreCell._get_kth_category_score(categories, scores, reverse=True, origin=0.5, k=0)
if score_name == PROMPT_STEREOTYPING
else CategoryScoreCell._get_kth_category_score(categories, scores, k=0)
)
lowest_category = escape(lowest_category)
lowest_score_description = (
"The model stereotypes the most in the category"
if score_name == PROMPT_STEREOTYPING
else "The model scores lowest in the category"
)
super().__init__(
f"The plot shows the score breakdown into individual categories.",
note,
bar_plot,
f"{lowest_score_description} **{lowest_category}**. ",
)