meghanaraok commited on
Commit
d8352e2
1 Parent(s): 77a3763

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
app.py CHANGED
@@ -160,8 +160,16 @@ def predict_icd(text_input, model_name, label_count):
160
  label_probabilities = {label_map[i]: prob * 100 for i, prob in enumerate(probabilities[0]) if label_map[i] in predicted_labels}
161
  y_pred = np.array(predicted_labels)
162
  y_pred = "\n".join(y_pred)
163
- label_dict = label_dict.set_index('icd9_code')['long_title'].to_dict()
164
- predicted_labels_with_titles = [(label, label_dict[label]) for label in predicted_labels]
 
 
 
 
 
 
 
 
165
 
166
  # html_output ="<h2>ICD Codes</h2>"
167
  # for label in predicted_labels:
 
160
  label_probabilities = {label_map[i]: prob * 100 for i, prob in enumerate(probabilities[0]) if label_map[i] in predicted_labels}
161
  y_pred = np.array(predicted_labels)
162
  y_pred = "\n".join(y_pred)
163
+ label_dict_df = pd.read_csv("data/mimic3/"+label_count+"/labels_dictionary_"+label_count+"_level_1.csv")
164
+ # label_dict = label_dict.set_index('icd9_code')['long_title'].to_dict()
165
+ # predicted_labels_with_titles = [(label, label_dict[label]) for label in predicted_labels]
166
+
167
+ label_dict_df['icd9_code'] = label_dict_df['icd9_code'].astype(str)
168
+ label_dict = label_dict_df.set_index('icd9_code')['long_title'].to_dict()
169
+
170
+ # Retrieve long titles from label_dict
171
+ predicted_labels_with_titles = [(label, label_dict.get(label, "Not Found")) for label in predicted_labels]
172
+
173
 
174
  # html_output ="<h2>ICD Codes</h2>"
175
  # for label in predicted_labels: