File size: 1,579 Bytes
3d78d90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274e3f9
3d78d90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274e3f9
 
73fa8ac
274e3f9
 
 
3d78d90
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import gradio as gr
import joblib
import numpy as np

# Load the model
model = joblib.load("random_forest_model.pkl")

# Prediction function
def predict_insulin(age, gender, height, weight, bmi, smoking, alcoholic, dm_years, hba1c, fbs, ppbs):
    gender = 1 if gender.lower() == "male" else 0
    smoking = 1 if smoking.lower() == "yes" else 0
    alcoholic = 1 if alcoholic.lower() == "yes" else 0

    features = np.array([[age, gender, height, weight, bmi, smoking, alcoholic, dm_years, hba1c, fbs, ppbs]])
    prediction = model.predict(features)[0]

    return "Needs Insulin" if prediction == 1 else "No Insulin Needed"

# Define the interface
iface = gr.Interface(
    fn=predict_insulin,
    inputs=[
        gr.Number(label="Age"),
        gr.Radio(["Male", "Female"], label="Gender"),
        gr.Number(label="Height (cm)"),
        gr.Number(label="Weight (kg)"),
        gr.Number(label="BMI"),
        gr.Radio(["Yes", "No"], label="Smoking"),
        gr.Radio(["Yes", "No"], label="Alcoholic"),
        gr.Number(label="Diabetes Duration (Years)"),
        gr.Number(label="HbA1c"),
        gr.Number(label="FBS"),
        gr.Number(label="PPBS")
    ],
    outputs=gr.Text(label="Prediction"),
    title="Insulin Dependency Predictor",
    description=(
        "Developed by **School of Allied and Healthcare Sciences, Malla Reddy University, Hyderabad, India**\n\n"
        "⚠️ *This is an experimental tool and should not be used for medical diagnosis. "
        "Always consult a licensed healthcare provider for medical advice.*"
    )
)

iface.launch()