Eval Math
eval_math(fname: str) -> Tuple[int, int, int, int, int]
Evaluate math answers from a CSV file using different sampling methods.
Reads a CSV file containing answers from different sampling strategies and grades them against the correct answers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fname
|
str
|
Path to the CSV file containing answers and correct solutions. |
required |
Returns:
| Type | Description |
|---|---|
int
|
A tuple containing (naive_sampling_correct, low_temp_sampling_correct, |
int
|
power_sampling_sliding_window_correct, power_sampling_correct, total), |
int
|
where each value represents the count of correct answers for that method |
int
|
and total is the number of questions evaluated. |
Source code in pita/utils/grading_utils/math/eval_math.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
math_results(fnames: List[str]) -> Dict[str, float]
Compute and display aggregate math results across multiple CSV files.
Evaluates answers from multiple CSV files using different sampling strategies and computes accuracy metrics for each strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fnames
|
List[str]
|
List of paths to CSV files containing answers and correct solutions. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
A dictionary containing accuracy metrics for each sampling strategy: |
Dict[str, float]
|
|
Dict[str, float]
|
|
Dict[str, float]
|
|
Dict[str, float]
|
|
Source code in pita/utils/grading_utils/math/eval_math.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | |
safe_grade(ans: str, correct_ans: str) -> int
Safely grade an answer against the correct answer.
Attempts to grade the given answer using the grade_answer function. Returns 0 if any exception occurs during grading.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ans
|
str
|
The student's answer to grade. |
required |
correct_ans
|
str
|
The correct answer to compare against. |
required |
Returns:
| Type | Description |
|---|---|
int
|
1 if the answer is correct, 0 if incorrect or if an exception occurred. |
Source code in pita/utils/grading_utils/math/eval_math.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | |