hiyata commited on
Commit
30b15ea
·
verified ·
1 Parent(s): 4c1d061

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -111,6 +111,7 @@ def predict(file_obj):
111
 
112
  try:
113
  sequences = parse_fasta(text)
 
114
  header, seq = sequences[0]
115
 
116
  raw_freq_vector = sequence_to_kmer_vector(seq)
@@ -149,10 +150,10 @@ def predict(file_obj):
149
  top_features.append("Others")
150
  top_values.append(others_sum)
151
 
152
- # Set base_values and expected_value to 0.5 for the binary classification baseline
153
  explanation = shap.Explanation(
154
  values=np.array(top_values),
155
- base_values=0.5,
156
  data=np.array([
157
  raw_freq_vector[kmer_dict[feat]] if feat != "Others"
158
  else np.sum(raw_freq_vector[others_mask])
@@ -160,7 +161,7 @@ def predict(file_obj):
160
  ]),
161
  feature_names=top_features
162
  )
163
- explanation.expected_value = 0.5
164
 
165
  fig = shap.plots._waterfall.waterfall_legacy(explanation, show=False)
166
 
@@ -202,3 +203,4 @@ iface = gr.Interface(
202
 
203
  if __name__ == "__main__":
204
  iface.launch(share=True)
 
 
111
 
112
  try:
113
  sequences = parse_fasta(text)
114
+ # For simplicity, process only the first sequence for plotting
115
  header, seq = sequences[0]
116
 
117
  raw_freq_vector = sequence_to_kmer_vector(seq)
 
150
  top_features.append("Others")
151
  top_values.append(others_sum)
152
 
153
+ # Set base_values and expected_value to 0 for the binary classification starting point
154
  explanation = shap.Explanation(
155
  values=np.array(top_values),
156
+ base_values=0.0,
157
  data=np.array([
158
  raw_freq_vector[kmer_dict[feat]] if feat != "Others"
159
  else np.sum(raw_freq_vector[others_mask])
 
161
  ]),
162
  feature_names=top_features
163
  )
164
+ explanation.expected_value = 0.0
165
 
166
  fig = shap.plots._waterfall.waterfall_legacy(explanation, show=False)
167
 
 
203
 
204
  if __name__ == "__main__":
205
  iface.launch(share=True)
206
+