Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -73,14 +73,10 @@ disease_dict = {
|
|
73 |
|
74 |
# Function to prepare data
|
75 |
def prepare_data(df):
|
76 |
-
|
77 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
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(
|