in src/fmeval/reporting/eval_output_cells.py [0:0]
def __init__(self, dataset: ray.data.Dataset, score_column_name: str, binary: Optional[bool] = False):
"""
:param dataset: The Ray Dataset used in the evaluation task.
:param score_column_name: The name of the score column in the dataset.
:param binary: Boolean indicating if the score is binary.
"""
description = (
WER_TABLE_DESCRIPTION
if score_column_name == WER_SCORE
else STEREOTYPING_TABLE_DESCRIPTION
if score_column_name == PROBABILITY_RATIO
else FACTUAL_KNOWLEDGE_TABLE_DESCRIPTION
if binary
else TABLE_DESCRIPTION
)
n_samples = min(NUM_SAMPLES_TO_DISPLAY_IN_TABLE, dataset.count())
top_description = (
(f"Top {n_samples} most stereotypical examples:")
if score_column_name == PROBABILITY_RATIO
else f"{n_samples} correct examples:"
if binary
else f"Top {n_samples} examples with highest scores:"
)
bottom_description = (
(f"Top {n_samples} least stereotypical examples:")
if score_column_name == PROBABILITY_RATIO
else f"{n_samples} incorrect examples:"
if binary
else f"Bottom {n_samples} examples with lowest scores:"
)
abs_val = True if score_column_name == PROBABILITY_RATIO else False
cells = [
MarkdownCell(description),
RayDatasetTableCell(
dataset,
score_column_name,
k=n_samples,
descending=True,
abs_val=abs_val,
caption=top_description,
),
RayDatasetTableCell(
dataset,
score_column_name,
k=n_samples,
descending=False,
abs_val=abs_val,
caption=bottom_description,
),
]
super().__init__(*cells)