Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #25

Closed
wants to merge 1 commit into from
Closed

Add files via upload #25

wants to merge 1 commit into from

Conversation

iruan29
Copy link
Collaborator

@iruan29 iruan29 commented Mar 9, 2025

revise main.py

What does this PR do?
fix no label problems

Please check all applicable items before submitting:

  • Have you read the contributing guidelines?
  • Does this PR only fix typos or improve the documentation (you can skip the other checks if that's the case)?
  • Is this PR related to a GitHub issue? If so, have you linked to it?
  • Have you written any necessary new tests?
  • Have all tests passed in your development environment, both existing and new?
  • Have you updated the documentation with your changes?
  • Have you run the pre-commit checks for code quality?

revise main.py
Copy link
Collaborator

@eggry eggry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution! Please address these comments.

return dataset


def eval_metrics(labels, preds):
if all(pd.isna(labels)):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use .all()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this case really need to be handled in a seperate if statement? Could this be directly integrated into the original control flow?

pd.Series([None] * len(dataset["label"]), dtype="boolean"),
dataset["label"],
),
if not dataset["label"].isna().all():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a flag hasLabels to replace all not dataset["label"].isna().all()

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be refactored as results = {...} if has_labels else {}

if k != "Annotation":
tb.add_row([k, v["labelled_coverage"], v["accuracy"], v["recall"], v["precision"], v["f1"]])
print(tb)
if not dataset["label"].isna().all():
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use the flag hasLabels

@@ -189,11 +202,10 @@ def main(
}

del evaluator
except Exception as e:
logger.error(f"Failed to evaluate {evaluator_id}: {e}")
finally:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this finally will result in leakage

"coverage": coverage,
"jailbreak_ratio": jailbreak_ratio,
"labelled_coverage": 0.00,
"accuracy": "N/A",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use pd.NA

@iruan29 iruan29 closed this Mar 10, 2025
@iruan29 iruan29 reopened this Mar 10, 2025
@iruan29 iruan29 closed this Mar 10, 2025
@iruan29 iruan29 deleted the rmy branch March 10, 2025 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG]When there is no label column in the dataset, an evaluation error is raised
2 participants