sheltonmaharesh commited on
Commit
e2c2f53
·
verified ·
1 Parent(s): 8191bad

Deploy backend Flask app

Browse files
Files changed (1) hide show
  1. bot_detector_api.py +6 -1
bot_detector_api.py CHANGED
@@ -96,7 +96,12 @@ def generate_shap_bot_attack_paragraph(index, shap_values, X, encoders=None, cla
96
 
97
  # Rank by contribution
98
  feature_contribs = list(zip(feature_names, decoded_vals.values(), shap_vals))
99
- feature_contribs = sorted(feature_contribs, key=lambda x: abs(x[2]), reverse=True)[:top_n]
 
 
 
 
 
100
 
101
  positive_impacts = []
102
  negative_impacts = []
 
96
 
97
  # Rank by contribution
98
  feature_contribs = list(zip(feature_names, decoded_vals.values(), shap_vals))
99
+ feature_contribs = sorted(
100
+ feature_contribs,
101
+ key=lambda x: abs(float(x[2])), # ensure it's a scalar
102
+ reverse=True
103
+ )[:top_n]
104
+
105
 
106
  positive_impacts = []
107
  negative_impacts = []