File size: 1,654 Bytes
159eb29 e6f657c a12b4ed 0ebcec0 a12b4ed e6f657c a12b4ed 159eb29 a12b4ed 0ebcec0 a12b4ed 0ebcec0 ee9627b 159eb29 c42a918 46d2751 a12b4ed e022594 0ebcec0 d63586f c42a918 a87cb20 e022594 |
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 |
import gradio as gr
import xgboost
import pandas as pd
import numpy as np
def predicter(SpO2, Age, Weight, Height, Temperature, Gender, Race):
xgb_reg = xgboost.XGBClassifier(tree_method = 'approx',
enable_categorical = True,
learning_rate=.1,
max_depth=2,
n_estimators=70,
early_stopping_rounds = 0,
scale_pos_weight=1)
xgb_reg.load_model('classifier_fewer_features_HH.json')
if Gender == "Male":
gen = "M"
elif Gender == "Female":
gen = "F"
cont_features = ['SpO2','anchor_age','weight','height','temperature']
cat_features = ['gender','race_group']
user_input = pd.DataFrame([[SpO2/100,Age/91,Weight/309,Height/213,Temperature/42.06,gen,Race]],columns = cont_features+cat_features)
user_input[cat_features] = user_input[cat_features].copy().astype('category')
pred = xgb_reg.predict_proba(user_input)
#return str(pred)
return {"Probability of Not Having Hidden Hypoxemia": float(pred[0][0]), "Probability of Having Hidden Hypoxemia": float(pred[0][1])}
demo = gr.Interface(
fn=predicter,
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"])],
outputs=[gr.Label()],
#outputs = gr.Textbox(label = "Probabilities"),
title = "Model Predictions"
)
demo.launch() |