Spaces:
Sleeping
Sleeping
Initial Commit
Browse files
app.py
CHANGED
@@ -83,18 +83,42 @@ custom_symptom_weightage = {
|
|
83 |
"Family Working in Public Exposed Places": 0.5,
|
84 |
}
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
# Create a bar chart to represent symptom weightage
|
87 |
def show_symptom_weightage(symptoms, weights):
|
88 |
-
plt.figure(figsize=(10, 6))
|
89 |
-
# Filter out the non-selected symptoms and their corresponding weights
|
90 |
selected_symptoms = [symptom for symptom, weight in zip(symptoms, weights) if weight > 0]
|
91 |
selected_weights = [weight for weight in weights if weight > 0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
plt.bar(selected_symptoms, selected_weights)
|
93 |
plt.xlabel("Symptom")
|
94 |
plt.ylabel("Weight")
|
95 |
-
plt.title("Weightage/Importance of Symptoms")
|
96 |
plt.xticks(rotation=45, ha='right')
|
97 |
plt.tight_layout()
|
|
|
98 |
# Save the plot as an image and return the file path
|
99 |
file_path = tempfile.NamedTemporaryFile(suffix=".png").name
|
100 |
plt.savefig(file_path)
|
|
|
83 |
"Family Working in Public Exposed Places": 0.5,
|
84 |
}
|
85 |
|
86 |
+
# Create a bar chart to represent symptom weightage
|
87 |
+
# def show_symptom_weightage(symptoms, weights):
|
88 |
+
# plt.figure(figsize=(10, 6))
|
89 |
+
# # Filter out the non-selected symptoms and their corresponding weights
|
90 |
+
# selected_symptoms = [symptom for symptom, weight in zip(symptoms, weights) if weight > 0]
|
91 |
+
# selected_weights = [weight for weight in weights if weight > 0]
|
92 |
+
# plt.bar(selected_symptoms, selected_weights)
|
93 |
+
# plt.xlabel("Symptom")
|
94 |
+
# plt.ylabel("Weight")
|
95 |
+
# plt.title("Weightage/Importance of Symptoms")
|
96 |
+
# plt.xticks(rotation=45, ha='right')
|
97 |
+
# plt.tight_layout()
|
98 |
+
# # Save the plot as an image and return the file path
|
99 |
+
# file_path = tempfile.NamedTemporaryFile(suffix=".png").name
|
100 |
+
# plt.savefig(file_path)
|
101 |
+
# plt.close()
|
102 |
+
# return file_path
|
103 |
+
|
104 |
# Create a bar chart to represent symptom weightage
|
105 |
def show_symptom_weightage(symptoms, weights):
|
|
|
|
|
106 |
selected_symptoms = [symptom for symptom, weight in zip(symptoms, weights) if weight > 0]
|
107 |
selected_weights = [weight for weight in weights if weight > 0]
|
108 |
+
|
109 |
+
# Check if any symptom is selected by the user
|
110 |
+
if len(selected_symptoms) == 0:
|
111 |
+
# If no symptom is selected, return None to indicate no bar graph should be displayed
|
112 |
+
return None
|
113 |
+
|
114 |
+
plt.figure(figsize=(10, 6))
|
115 |
plt.bar(selected_symptoms, selected_weights)
|
116 |
plt.xlabel("Symptom")
|
117 |
plt.ylabel("Weight")
|
118 |
+
plt.title("Weightage/Importance of Selected Symptoms")
|
119 |
plt.xticks(rotation=45, ha='right')
|
120 |
plt.tight_layout()
|
121 |
+
|
122 |
# Save the plot as an image and return the file path
|
123 |
file_path = tempfile.NamedTemporaryFile(suffix=".png").name
|
124 |
plt.savefig(file_path)
|