Spaces:
Sleeping
Sleeping
File size: 2,746 Bytes
b1cbeee 0ed1866 b1cbeee 6c8021f fd07503 b1cbeee b8ff2f0 b1cbeee b8ff2f0 b1cbeee 33ed0b4 b1cbeee | 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | 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()
|