fix dv
Browse files
app.py
CHANGED
@@ -248,16 +248,22 @@ if predict_button:
|
|
248 |
st.markdown("---")
|
249 |
st.markdown("### 📊 Drug Recommendations Visualization")
|
250 |
df_drugs = pd.DataFrame({"Drug": top_drugs, "Rank": range(len(top_drugs), 0, -1)}) # Reverse ranks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
251 |
fig = px.bar(df_drugs, x="Rank", y="Drug", title="Top Recommended Drugs",
|
252 |
labels={"Drug": "Drug Name", "Rank": "Rank"},
|
253 |
orientation='h', # Horizontal bar chart
|
254 |
color="Drug", # Color by drug name
|
255 |
-
color_discrete_map=
|
256 |
-
|
257 |
-
top_drugs[1]: "#a6e3a1", # Green
|
258 |
-
top_drugs[2]: "#f38ba8", # Red
|
259 |
-
top_drugs[3]: "#f2cdcd" # Flamingo
|
260 |
-
}) # Map colors to drugs
|
261 |
fig.update_layout(yaxis={'categoryorder':'total ascending'}) # Sort by rank
|
262 |
st.plotly_chart(fig, use_container_width=True)
|
263 |
|
|
|
248 |
st.markdown("---")
|
249 |
st.markdown("### 📊 Drug Recommendations Visualization")
|
250 |
df_drugs = pd.DataFrame({"Drug": top_drugs, "Rank": range(len(top_drugs), 0, -1)}) # Reverse ranks
|
251 |
+
color_map = {}
|
252 |
+
if len(top_drugs) >= 1:
|
253 |
+
color_map[top_drugs[0]] = "#b4befe" # Lavender
|
254 |
+
if len(top_drugs) >= 2:
|
255 |
+
color_map[top_drugs[1]] = "#a6e3a1" # Green
|
256 |
+
if len(top_drugs) >= 3:
|
257 |
+
color_map[top_drugs[2]] = "#f38ba8" # Red
|
258 |
+
if len(top_drugs) >= 4:
|
259 |
+
color_map[top_drugs[3]] = "#f2cdcd" # Flamingo
|
260 |
+
|
261 |
fig = px.bar(df_drugs, x="Rank", y="Drug", title="Top Recommended Drugs",
|
262 |
labels={"Drug": "Drug Name", "Rank": "Rank"},
|
263 |
orientation='h', # Horizontal bar chart
|
264 |
color="Drug", # Color by drug name
|
265 |
+
color_discrete_map=color_map) # Map colors to drugs
|
266 |
+
|
|
|
|
|
|
|
|
|
267 |
fig.update_layout(yaxis={'categoryorder':'total ascending'}) # Sort by rank
|
268 |
st.plotly_chart(fig, use_container_width=True)
|
269 |
|