Spaces:
Sleeping
Sleeping
| 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() |