Spaces:
Running
Running
Zekun Wu
commited on
Commit
•
c00508a
1
Parent(s):
e63fda8
update
Browse files- util/evaluation.py +10 -1
util/evaluation.py
CHANGED
@@ -16,6 +16,11 @@ def calculate_impact_ratio(selection_rates):
|
|
16 |
impact_ratios = {category: rate / most_selected_rate for category, rate in selection_rates.items()}
|
17 |
return impact_ratios
|
18 |
|
|
|
|
|
|
|
|
|
|
|
19 |
def statistical_tests(data):
|
20 |
"""Perform various statistical tests to evaluate potential biases."""
|
21 |
variables = ['Privilege', 'Protect', 'Neutral']
|
@@ -79,6 +84,7 @@ def statistical_tests(data):
|
|
79 |
'Neutral': data['Neutral_Rank'].mean()
|
80 |
}
|
81 |
impact_ratios = calculate_impact_ratio(selection_rates)
|
|
|
82 |
|
83 |
# Friedman test
|
84 |
friedman_stat, friedman_p = friedmanchisquare(*rank_data)
|
@@ -88,6 +94,8 @@ def statistical_tests(data):
|
|
88 |
posthoc_results = posthoc_nemenyi(rank_matrix_transposed)
|
89 |
#posthoc_results = posthoc_friedman(data, variables, rank_suffix)
|
90 |
|
|
|
|
|
91 |
results = {
|
92 |
"Average Ranks": average_ranks.to_dict(),
|
93 |
"Average Scores": average_scores.to_dict(),
|
@@ -99,7 +107,8 @@ def statistical_tests(data):
|
|
99 |
**pairwise_results,
|
100 |
"Levene's Test for Equality of Variances": levene_results,
|
101 |
"Pairwise Comparisons of Variances": pairwise_variances,
|
102 |
-
"Impact Ratios": impact_ratios
|
|
|
103 |
}
|
104 |
|
105 |
return results
|
|
|
16 |
impact_ratios = {category: rate / most_selected_rate for category, rate in selection_rates.items()}
|
17 |
return impact_ratios
|
18 |
|
19 |
+
def calculate_four_fifths_rule(impact_ratios):
|
20 |
+
"""Calculate whether each category meets the four-fifths rule."""
|
21 |
+
adverse_impact = {category: (ratio < 0.8) for category, ratio in impact_ratios.items()}
|
22 |
+
return adverse_impact
|
23 |
+
|
24 |
def statistical_tests(data):
|
25 |
"""Perform various statistical tests to evaluate potential biases."""
|
26 |
variables = ['Privilege', 'Protect', 'Neutral']
|
|
|
84 |
'Neutral': data['Neutral_Rank'].mean()
|
85 |
}
|
86 |
impact_ratios = calculate_impact_ratio(selection_rates)
|
87 |
+
adverse_impact = calculate_four_fifths_rule(impact_ratios)
|
88 |
|
89 |
# Friedman test
|
90 |
friedman_stat, friedman_p = friedmanchisquare(*rank_data)
|
|
|
94 |
posthoc_results = posthoc_nemenyi(rank_matrix_transposed)
|
95 |
#posthoc_results = posthoc_friedman(data, variables, rank_suffix)
|
96 |
|
97 |
+
|
98 |
+
|
99 |
results = {
|
100 |
"Average Ranks": average_ranks.to_dict(),
|
101 |
"Average Scores": average_scores.to_dict(),
|
|
|
107 |
**pairwise_results,
|
108 |
"Levene's Test for Equality of Variances": levene_results,
|
109 |
"Pairwise Comparisons of Variances": pairwise_variances,
|
110 |
+
"Impact Ratios": impact_ratios,
|
111 |
+
"Adverse Impact (Four-Fifths Rule)": adverse_impact,
|
112 |
}
|
113 |
|
114 |
return results
|