Spaces:
Sleeping
Sleeping
Zekun Wu
commited on
Commit
·
3b9517e
1
Parent(s):
fd1088f
update
Browse files- .DS_Store +0 -0
- util/evaluation.py +13 -0
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
util/evaluation.py
CHANGED
@@ -10,6 +10,11 @@ from scipy.stats import ttest_ind, friedmanchisquare, rankdata, ttest_rel
|
|
10 |
from statsmodels.stats.multicomp import pairwise_tukeyhsd
|
11 |
from scipy.stats import ttest_1samp
|
12 |
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def statistical_tests(data):
|
15 |
"""Perform various statistical tests to evaluate potential biases."""
|
@@ -68,6 +73,13 @@ def statistical_tests(data):
|
|
68 |
'Protect_Rank vs Neutral_Rank': variances['Protect_Rank'] > variances['Neutral_Rank']
|
69 |
}
|
70 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
# Friedman test
|
72 |
friedman_stat, friedman_p = friedmanchisquare(*rank_data)
|
73 |
|
@@ -87,6 +99,7 @@ def statistical_tests(data):
|
|
87 |
**pairwise_results,
|
88 |
"Levene's Test for Equality of Variances": levene_results,
|
89 |
"Pairwise Comparisons of Variances": pairwise_variances
|
|
|
90 |
}
|
91 |
|
92 |
return results
|
|
|
10 |
from statsmodels.stats.multicomp import pairwise_tukeyhsd
|
11 |
from scipy.stats import ttest_1samp
|
12 |
|
13 |
+
def calculate_impact_ratio(selection_rates):
|
14 |
+
"""Calculate the impact ratio for each category."""
|
15 |
+
most_selected_rate = max(selection_rates.values())
|
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."""
|
|
|
73 |
'Protect_Rank vs Neutral_Rank': variances['Protect_Rank'] > variances['Neutral_Rank']
|
74 |
}
|
75 |
|
76 |
+
selection_rates = {
|
77 |
+
'Privilege': data['Privilege_Rank'].mean(),
|
78 |
+
'Protect': data['Protect_Rank'].mean(),
|
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)
|
85 |
|
|
|
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
|