gradelib.scales - Letter grade scales

Common grading scales and tools for working with them.

gradelib.scales.DEFAULT_SCALE = {'A': 0.93, 'A+': 0.97, 'A-': 0.9, 'B': 0.83, 'B+': 0.87, 'B-': 0.8, 'C': 0.73, 'C+': 0.77, 'C-': 0.7, 'D': 0.6, 'F': 0}

The default grading scale.

gradelib.scales.ROUNDED_DEFAULT_SCALE = {'A': 0.925, 'A+': 0.965, 'A-': 0.895, 'B': 0.825, 'B+': 0.865, 'B-': 0.795, 'C': 0.725, 'C+': 0.765, 'C-': 0.695, 'D': 0.595, 'F': 0}

a rounded version of the default scale, where each threshold is one half point lower

gradelib.scales.map_scores_to_letter_grades(scores, scale=None) Series

Map each raw score to a letter grade.

Parameters:
  • scores (pandas.Series) – A series contains scores as floats between 0 and 1.

  • scale (OrderedDict) – An ordered dictionary mapping letter grades to their thresholds. Default: DEFAULT_SCALE.

Returns:

A series containing the resulting letter grades.

Return type:

pandas.Series

Raises:

ValueError – If the provided scale has invalid letter grades.

gradelib.scales.find_robust_scale(scores, scale=None, grade_gap=0.005, threshold_gap=0.01)

Find a robust grading scale.

Given an initial grading scale, finds the largest value of each threshold which is at least grade_gap larger than the highest grade below the threshold.

In other words, lowers the threshold for each letter grade until no student is agonizingly close to a higher letter grade.

Parameters:
  • scores (pd.Series) – A series containing the total scores for each student.

  • scale – An initial grading scale to relax and make robust. Default: DEFAULT_SCALE

  • grade_gap (float) – The minimum difference between a threshold and the highest grade below the threshold.

  • threshold_gap (float) – The minimum difference between consecutive thresholds.

Returns:

The robust grading scale.

Return type:

OrderedDict