DreamStream-1 commited on
Commit
c76c20f
·
verified ·
1 Parent(s): d8f1036

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -73,14 +73,10 @@ disease_dict = {
73
 
74
  # Function to prepare data
75
  def prepare_data(df):
76
- # Split the dataset into features and target
77
- X = df.iloc[:, :-1] # All columns except the last one (features)
78
- y = df.iloc[:, -1] # The last column (target)
79
-
80
- # Encode the target variable
81
  label_encoder = LabelEncoder()
82
  y_encoded = label_encoder.fit_transform(y)
83
-
84
  return X, y_encoded, label_encoder
85
 
86
  # Preparing training and testing data
@@ -244,7 +240,15 @@ def predict_disease(symptoms):
244
  prediction = info['model'].predict([input_test])[0]
245
  predicted_disease = label_encoder_train.inverse_transform([prediction])[0]
246
  predictions[model_name] = predicted_disease
247
- return predictions
 
 
 
 
 
 
 
 
248
 
249
  # Gradio Application Interface
250
  with gr.Blocks() as app:
@@ -280,7 +284,7 @@ with gr.Blocks() as app:
280
  symptom5 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 5")
281
 
282
  submit_disease = gr.Button(value="Predict Disease", variant="primary")
283
- disease_prediction_result = gr.Textbox(label="Predicted Diseases")
284
 
285
  submit_disease.click(
286
  lambda symptom1, symptom2, symptom3, symptom4, symptom5: predict_disease(
 
73
 
74
  # Function to prepare data
75
  def prepare_data(df):
76
+ X = df.iloc[:, :-1] # Features
77
+ y = df.iloc[:, -1] # Target
 
 
 
78
  label_encoder = LabelEncoder()
79
  y_encoded = label_encoder.fit_transform(y)
 
80
  return X, y_encoded, label_encoder
81
 
82
  # Preparing training and testing data
 
240
  prediction = info['model'].predict([input_test])[0]
241
  predicted_disease = label_encoder_train.inverse_transform([prediction])[0]
242
  predictions[model_name] = predicted_disease
243
+
244
+ # Create a Markdown table for displaying predictions
245
+ markdown_output = ["### Predicted Diseases"]
246
+ markdown_output.append("| Model | Predicted Disease |")
247
+ markdown_output.append("|-------|------------------|") # Table headers
248
+ for model_name, disease in predictions.items():
249
+ markdown_output.append(f"| {model_name} | {disease} |")
250
+
251
+ return "\n".join(markdown_output)
252
 
253
  # Gradio Application Interface
254
  with gr.Blocks() as app:
 
284
  symptom5 = gr.Dropdown(X_train.columns.tolist(), label="Select Symptom 5")
285
 
286
  submit_disease = gr.Button(value="Predict Disease", variant="primary")
287
+ disease_prediction_result = gr.Markdown(label="Predicted Diseases") # Use Markdown for predictions
288
 
289
  submit_disease.click(
290
  lambda symptom1, symptom2, symptom3, symptom4, symptom5: predict_disease(