Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import pickle
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
# Load the saved model
|
| 6 |
+
with open("model_AD.pkl", "rb") as f:
|
| 7 |
+
model = pickle.load(f)
|
| 8 |
+
|
| 9 |
+
def predict_pcos(input_features):
|
| 10 |
+
# Convert input features into a DataFrame (assuming 8 features here)
|
| 11 |
+
input_data = pd.DataFrame([input_features], columns=["Age (yrs)", "BMI", "Weight (Kg)", "Cycle length(days)", "Follicle No. (L)", "Follicle No. (R)", "AMH(ng/mL)", "beta-HCG(mIU/mL)"])
|
| 12 |
+
|
| 13 |
+
# Predict using the loaded model
|
| 14 |
+
prediction = model.predict(input_data)
|
| 15 |
+
|
| 16 |
+
return "PCOS Positive" if prediction[0] == 1 else "PCOS Negative"
|
| 17 |
+
|
| 18 |
+
# Define Gradio inputs and outputs
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=predict_pcos,
|
| 21 |
+
inputs=[
|
| 22 |
+
gr.inputs.Number(label="Age (yrs)"),
|
| 23 |
+
gr.inputs.Number(label="BMI"),
|
| 24 |
+
gr.inputs.Number(label="Weight (Kg)"),
|
| 25 |
+
gr.inputs.Number(label="Cycle length(days)"),
|
| 26 |
+
gr.inputs.Number(label="Follicle No. (L)"),
|
| 27 |
+
gr.inputs.Number(label="Follicle No. (R)"),
|
| 28 |
+
gr.inputs.Number(label="AMH(ng/mL)"),
|
| 29 |
+
gr.inputs.Number(label="beta-HCG(mIU/mL)")
|
| 30 |
+
],
|
| 31 |
+
outputs="text",
|
| 32 |
+
title="PCOS Detection",
|
| 33 |
+
description="Predicts PCOS based on user-provided medical data."
|
| 34 |
+
)
|
| 35 |
+
|
| 36 |
+
# Launch the Gradio interface
|
| 37 |
+
iface.launch()
|