Jishnnu commited on
Commit
9ae50c9
·
1 Parent(s): 1b06e57

Initial Commit

Browse files
Files changed (1) hide show
  1. app.py +9 -12
app.py CHANGED
@@ -64,7 +64,10 @@ class_index_mapping = {i: label for i, label in enumerate(class_labels)}
64
  # Create a bar chart to represent symptom weightage
65
  def show_symptom_weightage(symptoms, weights):
66
  plt.figure(figsize=(10, 6))
67
- plt.bar(symptoms, weights)
 
 
 
68
  plt.xlabel("Symptom")
69
  plt.ylabel("Weight")
70
  plt.title("Weightage/Importance of Symptoms")
@@ -164,20 +167,14 @@ def predict_covid(*args):
164
  # text_prob_positive = ((logreg_prob_positive + rf_prob_positive + dt_prob_positive +
165
  # knn_prob_positive + svm_prob_positive + ann_prob_positive) / 6) * 100
166
 
167
- # weights = [1.0] * len(symptoms)
168
- # probabilities = [logreg_prob_positive, rf_prob_positive, dt_prob_positive,
169
- # knn_prob_positive, svm_prob_positive, ann_prob_positive]
170
-
171
- # # Manually calculate the weighted average
172
- # total_weighted_prob = sum(prob * weight for prob, weight in zip(probabilities, weights))
173
- # total_weight = sum(weights)
174
- # text_prob_positive = (total_weighted_prob / total_weight) * 100 if total_weight != 0 else 0.0
175
-
176
- weights = [0.2, 0.2, 0.2, 0.2, 0.1, 0.2] # Example weights for each model
177
  probabilities = [logreg_prob_positive, rf_prob_positive, dt_prob_positive,
178
  knn_prob_positive, svm_prob_positive, ann_prob_positive]
179
 
180
- text_prob_positive = np.average(probabilities, weights=weights) * 100
 
 
 
181
 
182
  # Visualize the symptom weightage/importance
183
  symptom_weightage_img = show_symptom_weightage(column_names[:-1], weights)
 
64
  # Create a bar chart to represent symptom weightage
65
  def show_symptom_weightage(symptoms, weights):
66
  plt.figure(figsize=(10, 6))
67
+ # Filter out the non-selected symptoms and their corresponding weights
68
+ selected_symptoms = [symptom for symptom, weight in zip(symptoms, weights) if weight > 0]
69
+ selected_weights = [weight for weight in weights if weight > 0]
70
+ plt.bar(selected_symptoms, selected_weights)
71
  plt.xlabel("Symptom")
72
  plt.ylabel("Weight")
73
  plt.title("Weightage/Importance of Symptoms")
 
167
  # text_prob_positive = ((logreg_prob_positive + rf_prob_positive + dt_prob_positive +
168
  # knn_prob_positive + svm_prob_positive + ann_prob_positive) / 6) * 100
169
 
170
+ weights = [1.0 if symptom else 0.0 for symptom in symptoms]
 
 
 
 
 
 
 
 
 
171
  probabilities = [logreg_prob_positive, rf_prob_positive, dt_prob_positive,
172
  knn_prob_positive, svm_prob_positive, ann_prob_positive]
173
 
174
+ # Manually calculate the weighted average
175
+ total_weighted_prob = sum(prob * weight for prob, weight in zip(probabilities, weights))
176
+ total_weight = sum(weights)
177
+ text_prob_positive = (total_weighted_prob / total_weight) * 100 if total_weight != 0 else 0.0
178
 
179
  # Visualize the symptom weightage/importance
180
  symptom_weightage_img = show_symptom_weightage(column_names[:-1], weights)