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