Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions langtest/transform/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Result,
)
from ..utils.custom_types.helpers import default_user_prompt
from ..utils.util_metrics import calculate_f1_score

nest_asyncio.apply()

Expand Down Expand Up @@ -893,8 +894,12 @@ def run(
y_pred = y_pred[valid_indices]
y_true = y_true.explode()
y_pred = y_pred.explode()
y_pred = y_pred.apply(lambda x: x.split("-")[-1])
y_true = y_true.apply(lambda x: x.split("-")[-1])
y_pred = y_pred.apply(lambda x: x.split("-")[-1]).reset_index(
drop=True
)
y_true = y_true.apply(lambda x: x.split("-")[-1]).reset_index(
drop=True
)

elif isinstance(data[0], SequenceClassificationSample):
y_true = pd.Series(data).apply(
Expand Down
5 changes: 2 additions & 3 deletions langtest/transform/fairness.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,11 @@ async def run(

"""
progress = kwargs.get("progress_bar", False)

for sample in sample_list:
data = gendered_data[sample.test_case]
if len(data[0]) > 0:
macro_f1_score = calculate_f1_score(
[x[0] for x in data[0]], data[1], average="macro", zero_division=0
data[0].to_list(), data[1].to_list(), average="macro", zero_division=0
)
else:
macro_f1_score = 1
Expand Down Expand Up @@ -232,7 +231,7 @@ async def run(
data = gendered_data[sample.test_case]
if len(data[0]) > 0:
macro_f1_score = calculate_f1_score(
[x[0] for x in data[0]], data[1], average="macro", zero_division=0
data[0].to_list(), data[1].to_list(), average="macro", zero_division=0
)
else:
macro_f1_score = 1
Expand Down