File size: 2,196 Bytes
e79d769
 
 
 
 
 
224c828
 
35ee2c7
e79d769
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import gradio as gr
import pandas as pd
import pickle

# تحميل الموديل

import joblib

model = joblib.load("diabetes_model.pkl")

def predict_diabetes(age, gender, bmi, blood_pressure, fasting_glucose,
                     insulin, hba1c, cholesterol, triglycerides,
                     physical_activity, calories, sugar,
                     sleep_hours, stress_level, family_history,
                     waist):

    # تجهيز الداتا في DataFrame
    data = pd.DataFrame([{
        "age": age,
        "gender": gender,
        "bmi": bmi,
        "blood_pressure": blood_pressure,
        "fasting_glucose_level": fasting_glucose,
        "insulin_level": insulin,
        "HbA1c_level": hba1c,
        "cholesterol_level": cholesterol,
        "triglycerides_level": triglycerides,
        "physical_activity_level": physical_activity,
        "daily_calorie_intake": calories,
        "sugar_intake_grams_per_day": sugar,
        "sleep_hours": sleep_hours,
        "stress_level": stress_level,
        "family_history_diabetes": family_history,
        "waist_circumference_cm": waist
    }])

    prediction = model.predict(data)

    return prediction[0]


interface = gr.Interface(
    fn=predict_diabetes,
    inputs=[
        gr.Number(label="Age"),
        gr.Dropdown(["Male", "Female"], label="Gender"),
        gr.Number(label="BMI"),
        gr.Number(label="Blood Pressure"),
        gr.Number(label="Fasting Glucose Level"),
        gr.Number(label="Insulin Level"),
        gr.Number(label="HbA1c Level"),
        gr.Number(label="Cholesterol Level"),
        gr.Number(label="Triglycerides Level"),
        gr.Number(label="Physical Activity Level"),
        gr.Number(label="Daily Calorie Intake"),
        gr.Number(label="Sugar Intake (grams/day)"),
        gr.Number(label="Sleep Hours"),
        gr.Number(label="Stress Level"),
        gr.Dropdown(["Yes", "No"], label="Family History Diabetes"),
        gr.Number(label="Waist Circumference (cm)")
    ],
    outputs=gr.Textbox(label="Predicted Diabetes Risk"),
    title="Diabetes Risk Prediction",
    description="Enter patient data to predict diabetes risk category"
)

interface.launch()