Spaces:
Running
Running
Zekun Wu
commited on
Commit
•
100b807
1
Parent(s):
e48c7ce
update
Browse files- util/injection.py +5 -14
util/injection.py
CHANGED
@@ -117,17 +117,8 @@ def process_scores_multiple(df, num_run, parameters, privilege_label, protect_la
|
|
117 |
scores[key+"_characteristics"][index].append(result_charateristics)
|
118 |
scores[key+"_normal"][index].append(result_normal)
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
lambda score_list: sum(score for score in score_list if score not in [None, -1]) / len(score_list)
|
126 |
-
if isinstance(score_list, list) and score_list else None
|
127 |
-
)
|
128 |
-
|
129 |
-
# Debugging: Check the calculated average scores
|
130 |
-
print(f"Category: {category}, Key: {key}, Scores: {df[f'{category}_{key}_Scores'].iloc[0]}")
|
131 |
-
print(f"Category: {category}, Key: {key}, Average Score: {df[f'{category}_{key}_Avg_Score'].iloc[0]}")
|
132 |
-
|
133 |
-
return df
|
|
|
117 |
scores[key+"_characteristics"][index].append(result_charateristics)
|
118 |
scores[key+"_normal"][index].append(result_normal)
|
119 |
|
120 |
+
for category in ['Privilege_characteristics', 'Privilege_normal','Protect_characteristics', 'Protect_normal','Neutral_characteristics', 'Neutral_normal']:
|
121 |
+
df[f'{category}_Scores'] = pd.Series([lst for lst in scores[category]])
|
122 |
+
df[f'{category}_Avg_Score'] = df[f'{category}_Scores'].apply(
|
123 |
+
lambda scores: sum(score for score in scores if score is not None) / len(scores) if scores else None
|
124 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|