Update app.py
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import numpy as np
|
|
7 |
def greet(name):
|
8 |
return "Hello " + name + "!!"
|
9 |
|
10 |
-
def
|
11 |
xgb_reg = xgboost.XGBClassifier(tree_method = 'approx',
|
12 |
enable_categorical = True,
|
13 |
learning_rate=.1,
|
@@ -23,14 +23,18 @@ def predict(SpO2, Age, Weight, Height, Temperature, Gender, Race):
|
|
23 |
elif Gender == "Female":
|
24 |
gen = "F"
|
25 |
|
|
|
|
|
26 |
|
27 |
-
user_input = pd.DataFrame([SpO2/100,Age/91,Weight/309,Height/213,Temperature/42.06,gen,Race])
|
|
|
|
|
28 |
|
29 |
-
return
|
30 |
|
31 |
|
32 |
demo = gr.Interface(
|
33 |
-
fn=
|
34 |
inputs=[gr.Slider(0, 100),"number",gr.inputs.Number(label = "Weight in kg"),gr.inputs.Number(label = "Height in cm"),gr.inputs.Number(label = "Temperature in Celcius"),gr.Radio(["Male", "Female"]),gr.Radio(["White", "Black", "Asian", "Hispanic", "Other"])],
|
35 |
outputs=["text"],
|
36 |
)
|
|
|
7 |
def greet(name):
|
8 |
return "Hello " + name + "!!"
|
9 |
|
10 |
+
def predicter(SpO2, Age, Weight, Height, Temperature, Gender, Race):
|
11 |
xgb_reg = xgboost.XGBClassifier(tree_method = 'approx',
|
12 |
enable_categorical = True,
|
13 |
learning_rate=.1,
|
|
|
23 |
elif Gender == "Female":
|
24 |
gen = "F"
|
25 |
|
26 |
+
cont_features = ['SpO2','anchor_age','weight','height','temperature']
|
27 |
+
cat_features = ['gender','race_group']
|
28 |
|
29 |
+
user_input = pd.DataFrame([[SpO2/100,Age/91,Weight/309,Height/213,Temperature/42.06,gen,Race]],columns = cont_features+cat_features)
|
30 |
+
user_input[cat_features] = user_input[cat_features].copy().astype('category')
|
31 |
+
pred = xgb_reg.predict(user_input)
|
32 |
|
33 |
+
return pred
|
34 |
|
35 |
|
36 |
demo = gr.Interface(
|
37 |
+
fn=predicter,
|
38 |
inputs=[gr.Slider(0, 100),"number",gr.inputs.Number(label = "Weight in kg"),gr.inputs.Number(label = "Height in cm"),gr.inputs.Number(label = "Temperature in Celcius"),gr.Radio(["Male", "Female"]),gr.Radio(["White", "Black", "Asian", "Hispanic", "Other"])],
|
39 |
outputs=["text"],
|
40 |
)
|