Spaces:
Running
Running
meghanaraok
commited on
Commit
•
77a3763
1
Parent(s):
b6b06da
Update app.py
Browse files
app.py
CHANGED
@@ -160,11 +160,20 @@ 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 |
|
|
|
|
|
|
|
|
|
|
|
164 |
html_output ="<h2>ICD Codes</h2>"
|
165 |
-
for label in
|
166 |
color = hash_to_color(label)
|
167 |
-
html_output += f"<div style='background-color: {color}; padding: 5px; margin-bottom: 5px;'>{label} <span style='float:right;'>{label_probabilities[label]:.2f}%</span></div>"
|
|
|
|
|
168 |
|
169 |
return html_output
|
170 |
|
|
|
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:
|
168 |
+
# color = hash_to_color(label)
|
169 |
+
# html_output += f"<div style='background-color: {color}; padding: 5px; margin-bottom: 5px;'>{label} <span style='float:right;'>{label_probabilities[label]:.2f}%</span></div>"
|
170 |
+
|
171 |
html_output ="<h2>ICD Codes</h2>"
|
172 |
+
for label, title in predicted_labels_with_titles:
|
173 |
color = hash_to_color(label)
|
174 |
+
html_output += f"<div style='background-color: {color}; padding: 5px; margin-bottom: 5px;'>{label} - {title} <span style='float:right;'>{label_probabilities[label]:.2f}%</span></div>"
|
175 |
+
|
176 |
+
|
177 |
|
178 |
return html_output
|
179 |
|