karalif commited on
Commit
8970067
verified
1 Parent(s): fb998f7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
app.py CHANGED
@@ -109,16 +109,16 @@ def predict(user_input_text):
109
 
110
  response += "<br>TOP 2 MOST INFLUENTIAL WORDS FOR EACH LABEL:<br>"
111
  for i, explanations in enumerate(explanation_lists):
112
- label = labels[i]
113
- response += f"{label}:<br>"
114
- for explanation in explanations:
115
- if explanation.explainer == 'Partition SHAP':
116
- sorted_scores = sorted(enumerate(explanation.scores), key=lambda x: abs(x[1]), reverse=True)[:2]
117
- if sorted_scores: # Check if the list is not empty
118
- tokens = replace_encoding(explanation.tokens)
119
- tokens = [tokens[idx] for idx, _ in sorted_scores]
120
- formatted_output = ' '.join(tokens)
121
- response += f"{formatted_output}<br>"
122
 
123
  return response
124
 
 
109
 
110
  response += "<br>TOP 2 MOST INFLUENTIAL WORDS FOR EACH LABEL:<br>"
111
  for i, explanations in enumerate(explanation_lists):
112
+ label = labels[i]
113
+ response += f"{label}:<br>"
114
+ for explanation in explanations:
115
+ if explanation.explainer == 'Partition SHAP':
116
+ sorted_scores = sorted(enumerate(explanation.scores), key=lambda x: abs(x[1]), reverse=True)[:2]
117
+ if sorted_scores: # Check if the list is not empty
118
+ tokens = replace_encoding(explanation.tokens)
119
+ tokens = [tokens[idx] for idx, _ in sorted_scores]
120
+ formatted_output = ' '.join(tokens)
121
+ response += f"{formatted_output}<br>"
122
 
123
  return response
124