Zekun Wu commited on
Commit
fd1088f
1 Parent(s): 3f8a515
Files changed (1) hide show
  1. util/evaluation.py +23 -0
util/evaluation.py CHANGED
@@ -47,6 +47,27 @@ def statistical_tests(data):
47
  wilcoxon_stat, wilcoxon_p = np.nan, "Sample size too small for Wilcoxon test."
48
  pairwise_results['Wilcoxon Test'][pair_rank_score] = {"Statistic": wilcoxon_stat, "p-value": wilcoxon_p}
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
  # Friedman test
51
  friedman_stat, friedman_p = friedmanchisquare(*rank_data)
52
 
@@ -64,6 +85,8 @@ def statistical_tests(data):
64
  "Post-hoc": posthoc_results
65
  },
66
  **pairwise_results,
 
 
67
  }
68
 
69
  return results
 
47
  wilcoxon_stat, wilcoxon_p = np.nan, "Sample size too small for Wilcoxon test."
48
  pairwise_results['Wilcoxon Test'][pair_rank_score] = {"Statistic": wilcoxon_stat, "p-value": wilcoxon_p}
49
 
50
+ # Levene's Test for Equality of Variances
51
+ levene_results = {}
52
+ levene_privilege_protect = levene(data['Privilege_Rank'], data['Protect_Rank'])
53
+ levene_privilege_neutral = levene(data['Privilege_Rank'], data['Neutral_Rank'])
54
+ levene_protect_neutral = levene(data['Protect_Rank'], data['Neutral_Rank'])
55
+
56
+ levene_results['Privilege vs Protect'] = {"Statistic": levene_privilege_protect.statistic,
57
+ "p-value": levene_privilege_protect.pvalue}
58
+ levene_results['Privilege vs Neutral'] = {"Statistic": levene_privilege_neutral.statistic,
59
+ "p-value": levene_privilege_neutral.pvalue}
60
+ levene_results['Protect vs Neutral'] = {"Statistic": levene_protect_neutral.statistic,
61
+ "p-value": levene_protect_neutral.pvalue}
62
+
63
+ # Calculate variances for ranks
64
+ variances = {col: data[col].var() for col in rank_columns}
65
+ pairwise_variances = {
66
+ 'Privilege_Rank vs Protect_Rank': variances['Privilege_Rank'] > variances['Protect_Rank'],
67
+ 'Privilege_Rank vs Neutral_Rank': variances['Privilege_Rank'] > variances['Neutral_Rank'],
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
 
 
85
  "Post-hoc": posthoc_results
86
  },
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