Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| import numpy as np | |
| from joblib import load | |
| rf = load("model_smoke_pred.pkl") | |
| columns = [ | |
| "age", | |
| "height(cm)", | |
| "weight(kg)", | |
| "waist(cm)", | |
| "eyesight(left)", | |
| "eyesight(right)", | |
| "hearing(left)", | |
| "hearing(right)", | |
| "systolic", | |
| "relaxation", | |
| "fasting_blood_sugar", | |
| "cholesterol", | |
| "triglyceride", | |
| "hdl", | |
| "ldl", | |
| "hemoglobin", | |
| "urine_protein", | |
| "serum_creatinine", | |
| "ast", | |
| "alt", | |
| "gtp", | |
| "dental_caries", | |
| ] | |
| def predict( | |
| age, | |
| height, | |
| weight, | |
| waist, | |
| eyesight_left, | |
| eyesight_right, | |
| hearing_left, | |
| hearing_right, | |
| systolic, | |
| relaxation, | |
| fasting_blood_sugar, | |
| cholesterol, | |
| triglyceride, | |
| hdl, | |
| ldl, | |
| hemoglobin, | |
| urine_protein, | |
| serum_creatinine, | |
| ast, | |
| alt, | |
| gtp, | |
| dental_caries, | |
| ): | |
| data = np.array( | |
| [ | |
| [ | |
| age, | |
| height, | |
| weight, | |
| waist, | |
| eyesight_left, | |
| eyesight_right, | |
| hearing_left, | |
| hearing_right, | |
| systolic, | |
| relaxation, | |
| fasting_blood_sugar, | |
| cholesterol, | |
| triglyceride, | |
| hdl, | |
| ldl, | |
| hemoglobin, | |
| urine_protein, | |
| serum_creatinine, | |
| ast, | |
| alt, | |
| gtp, | |
| dental_caries, | |
| ] | |
| ] | |
| ) | |
| pred = rf.predict(data)[0] | |
| return {"fumante": pred} | |
| inputs = [ | |
| gr.Number(label="age"), | |
| gr.Number(label="height(cm)"), | |
| gr.Number(label="weight(kg)"), | |
| gr.Number(label="waist(cm)"), | |
| gr.Number(label="eyesight(left)"), | |
| gr.Number(label="eyesight(right)"), | |
| gr.Slider(minimum=0, maximum=1, label="hearing(left)"), # Assuming it's a boolean | |
| gr.Slider(minimum=0, maximum=1, label="hearing(right)"), # Assuming it's a boolean | |
| gr.Number(label="systolic"), | |
| gr.Number(label="relaxation"), | |
| gr.Number(label="fasting_blood_sugar"), | |
| gr.Number(label="cholesterol"), | |
| gr.Number(label="triglyceride"), | |
| gr.Number(label="hdl"), | |
| gr.Number(label="ldl"), | |
| gr.Number(label="hemoglobin"), | |
| gr.Number(label="urine_protein"), | |
| gr.Number(label="serum_creatinine"), | |
| gr.Number(label="ast"), | |
| gr.Number(label="alt"), | |
| gr.Number(label="gtp"), | |
| gr.Slider(minimum=0, maximum=1, label="dental_caries"), # Assuming it's a boolean | |
| ] | |
| output = gr.Label(num_top_classes=1) | |
| iface = gr.Interface( | |
| fn=predict, | |
| inputs=inputs, | |
| outputs=output, | |
| description="O modelo em questão tenta realizar a predição se o usuario é ou não fumante.", | |
| ) | |
| iface.launch() | |