Spaces:
Sleeping
Sleeping
Commit ·
081c6ca
1
Parent(s): 0b1e995
feat(graders): add letter grade, summary and full metrics dict to grade_episode()
Browse files
graders/programmatic_grader.py
CHANGED
|
@@ -7,16 +7,35 @@ from graders.easy_grader import grade_easy
|
|
| 7 |
from graders.medium_grader import grade_medium
|
| 8 |
from graders.hard_grader import grade_hard
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
def grade_episode(history: list[dict]) -> dict[str, Any]:
|
| 11 |
if not history:
|
| 12 |
-
return {"error": "
|
| 13 |
|
| 14 |
-
easy_score
|
| 15 |
medium_score = grade_medium(history)
|
| 16 |
-
hard_score
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
return {
|
| 19 |
-
"
|
| 20 |
-
"
|
| 21 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
}
|
|
|
|
| 7 |
from graders.medium_grader import grade_medium
|
| 8 |
from graders.hard_grader import grade_hard
|
| 9 |
|
| 10 |
+
def get_letter_grade(score: float) -> str:
|
| 11 |
+
if score >= 0.90: return "A+"
|
| 12 |
+
if score >= 0.80: return "A"
|
| 13 |
+
if score >= 0.70: return "B"
|
| 14 |
+
if score >= 0.60: return "C"
|
| 15 |
+
if score >= 0.50: return "D"
|
| 16 |
+
return "F"
|
| 17 |
+
|
| 18 |
def grade_episode(history: list[dict]) -> dict[str, Any]:
|
| 19 |
if not history:
|
| 20 |
+
return {"error": "No history provided", "score": 0.0, "grade": "F"}
|
| 21 |
|
| 22 |
+
easy_score = grade_easy(history)
|
| 23 |
medium_score = grade_medium(history)
|
| 24 |
+
hard_score = grade_hard(history)
|
| 25 |
+
|
| 26 |
+
final_score = hard_score
|
| 27 |
+
grade = get_letter_grade(final_score)
|
| 28 |
|
| 29 |
return {
|
| 30 |
+
"overall_score": round(final_score, 4),
|
| 31 |
+
"letter_grade": grade,
|
| 32 |
+
"summary": f"Episode completed with {len(history)} turns. Final score: {final_score}.",
|
| 33 |
+
"metrics": {
|
| 34 |
+
"easy": easy_score,
|
| 35 |
+
"medium": medium_score,
|
| 36 |
+
"hard": hard_score,
|
| 37 |
+
"turns": len(history),
|
| 38 |
+
"unique_strategies": len(set(h.get("strategy_type") for h in history)),
|
| 39 |
+
"unique_categories": len(set(h.get("target_category") for h in history)),
|
| 40 |
+
}
|
| 41 |
}
|